@Test public void getOrSetValue() { ObjectValue ov = PropertyValue.createObject(); PropertyValue val = new PropertyValue("k1", "v"); ov.setPropertyValue(val); PropertyValue val2 = ov.getOrSetValue("k2", () -> new PropertyValue("foo", "bar")); PropertyValue pv = ov.getOrSetValue("foo", () -> new PropertyValue("foo", "bar")); assertThat(pv).isNotNull(); assertThat(ov.getValues()).hasSize(3); assertThat(val).isEqualTo(ov.getPropertyValue("k1")); assertThat(val2).isEqualTo(ov.getPropertyValue("k2")); assertThat(pv).isEqualTo(ov.getPropertyValue("foo")); }
public <T extends PropertyValue> T getOrSetValue(String name, Supplier<T> valueSupplier){ T field = (T)this.fields.get(name); if(field==null){ checkImmutable(); field = valueSupplier.get(); this.fields.put(name, field); incrementVersion(); } return field; }
ObjectValue extends PropertyValue { public <T extends PropertyValue> T getOrSetValue(String name, Supplier<T> valueSupplier){ T field = (T)this.fields.get(name); if(field==null){ checkImmutable(); field = valueSupplier.get(); this.fields.put(name, field); incrementVersion(); } return field; } }
ObjectValue extends PropertyValue { public <T extends PropertyValue> T getOrSetValue(String name, Supplier<T> valueSupplier){ T field = (T)this.fields.get(name); if(field==null){ checkImmutable(); field = valueSupplier.get(); this.fields.put(name, field); incrementVersion(); } return field; } ObjectValue( String key); }
ObjectValue extends PropertyValue { public <T extends PropertyValue> T getOrSetValue(String name, Supplier<T> valueSupplier){ T field = (T)this.fields.get(name); if(field==null){ checkImmutable(); field = valueSupplier.get(); this.fields.put(name, field); incrementVersion(); } return field; } 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); }
ObjectValue extends PropertyValue { public <T extends PropertyValue> T getOrSetValue(String name, Supplier<T> valueSupplier){ T field = (T)this.fields.get(name); if(field==null){ checkImmutable(); field = valueSupplier.get(); this.fields.put(name, field); incrementVersion(); } return field; } 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);  }