Skip to content

Commit dad0e73

Browse files
committed
reverted b355fd9
1 parent 9759023 commit dad0e73

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Changelog
22

33
## [Unreleased]
4-
### Changed
5-
- `LocalProperties` of `AbstractGML` and `AbstractAssociation` objects are no longer copied by default when using
6-
`Copier`.
74

85
## [2.0.0] - 2026-03-31
96
### Changed

src/main/java/org/xmlobjects/gml/model/common/LocalProperties.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package org.xmlobjects.gml.model.common;
77

88
import org.xmlobjects.copy.CopyContext;
9-
import org.xmlobjects.copy.CopyMode;
109
import org.xmlobjects.copy.Copyable;
1110

1211
import java.io.Serializable;
@@ -26,8 +25,9 @@ public <T> T get(String name, Class<T> type) {
2625
if (properties != null) {
2726
Object value = properties.get(name);
2827
return value != null && type.isAssignableFrom(value.getClass()) ? type.cast(value) : null;
29-
} else
28+
} else {
3029
return null;
30+
}
3131
}
3232

3333
public boolean getAndCompare(String name, Object expectedValue) {
@@ -54,8 +54,9 @@ public boolean contains(String name) {
5454
}
5555

5656
public void set(String name, Object value) {
57-
if (properties == null)
57+
if (properties == null) {
5858
properties = new HashMap<>();
59+
}
5960

6061
properties.put(name, value);
6162
}
@@ -65,17 +66,29 @@ public boolean isEmpty() {
6566
}
6667

6768
public void remove(String name) {
68-
if (properties != null)
69+
if (properties != null) {
6970
properties.remove(name);
71+
}
7072
}
7173

7274
public void clear() {
73-
if (properties != null)
75+
if (properties != null) {
7476
properties.clear();
77+
}
7578
}
7679

7780
@Override
78-
public LocalProperties newInstance(CopyMode mode, CopyContext context) {
79-
return context.isRoot() ? new LocalProperties() : null;
81+
public void shallowCopyTo(LocalProperties dest, CopyContext context) {
82+
if (properties != null) {
83+
dest.properties = new HashMap<>(properties);
84+
}
85+
}
86+
87+
@Override
88+
public void deepCopyTo(LocalProperties dest, CopyContext context) {
89+
if (properties != null) {
90+
dest.properties = new HashMap<>(properties.size());
91+
properties.forEach((name, value) -> dest.properties.put(name, context.deepCopy(value)));
92+
}
8093
}
8194
}

0 commit comments

Comments
 (0)