219 | | * @return <code>true</code>, if no merge is needed or merge is performed already. |
| 219 | * Tries to merge a primitive <code>other</code> into an existing primitive with the same id. |
| 220 | * |
| 221 | * @param myPrimitives the complete set of my primitives (potential merge targets) |
| 222 | * @param myPrimitivesWithID the map of primitives (potential merge targets) with an id <> 0, for faster lookup |
| 223 | * by id. Key is the id, value the primitive with the given value. myPrimitives.valueSet() is a |
| 224 | * subset of primitives. |
| 225 | * @param other the other primitive which is to be merged with a primitive in primitives if possible |
| 226 | * @return true, if this method was able to merge <code>other</code> with an existing node; false, otherwise |
222 | | Collection<P> primitives, HashMap<Long, P> hash, P other) { |
223 | | // Fast-path merging of identical objects |
224 | | if (hash.containsKey(other.id)) { |
225 | | P my = hash.get(other.id); |
226 | | if (my.realEqual(other, true)) { |
| 229 | Collection<P> myPrimitives, HashMap<Long, P> myPrimitivesWithID, P other) { |
| 230 | |
| 231 | // merge other into an existing primitive with the same id, if possible |
| 232 | // |
| 233 | if (myPrimitivesWithID.containsKey(other.id)) { |
| 234 | P my = myPrimitivesWithID.get(other.id); |
| 235 | if (my.realEqual(other, true /* compare semantic fields only */)) { |
| 236 | // make sure the merge target becomes the higher version number |
| 237 | // and the later timestamp |
| 238 | // |
| 239 | my.version = Math.max(other.version, my.version); |
| 240 | if (other.getTimestamp().after(my.getTimestamp())) { |
| 241 | my.setTimestamp(other.getTimestamp()); |
| 242 | } |