ObjectValue extends PropertyValue { @Override protected ObjectValue deepClone(){ ObjectValue newProp = new ObjectValue(getKey()); newProp.setParent(getParent()); newProp.setMeta(getMeta()); fields.values().forEach(c -> newProp.setPropertyValue(c.deepClone().mutable())); newProp.setVersion(getVersion()); return newProp; } ObjectValue( String key); @Override ValueType getValueType(); Collection<PropertyValue> getValues(); Set<String> getKeys(); PropertyValue getPropertyValue(String name); String getValue(); @Override PropertyValue setValue(String value); String getValue(String key); T getOrSetValue(String name, Supplier<T> valueSupplier); @Override int getSize(); ObjectValue setValues(Map<String, String> config); ObjectValue setValues(Map<String, String> config, String source, boolean overwriteExisting); @Override ObjectValue toObjectValue(); @Override ListValue toListValue(); @Override Iterator<PropertyValue> iterator(); ObjectValue setValue(String k, String v); ListValue addList(String key); ObjectValue addObject(String key); PropertyValue setValueWithCompositeKey(String key, String value); Collection<PropertyValue> setValueWithCompositeKey(Map<String,String> values); @Override Map<String,String> toMap(); @Override Map<String,String> toLocalMap(); @Override ObjectValue mutable(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static ObjectValue from(Collection<PropertyValue> values);  }
@Test public void deepClone() { ObjectValue ov1 = PropertyValue.createObject("foo"); ov1.addList("list"); ObjectValue ov2 = ov1.deepClone(); assertThat(ov1.getValues()!=ov2.getValues()).isTrue(); assertThat(ov1.getMeta()!=ov2.getMeta()).isTrue(); assertThat(ov1.equals(ov2)).isTrue(); assertThat(ov1.iterator().next()!=ov2.iterator().next()).isTrue(); }