@Test public void testToFromMap() { class Clazz extends AttrComposite { public AttrString defValue = attributes.register("defValue", AttrString.builder().defaultValue("foo")); public AttrString nullValue = attributes.register("nullValue", AttrString.builder().defaultValue(null)); public AttrString otherValue = attributes.register("otherValue", AttrString.builder().defaultValue(null)); } AliasMapper mapper = new AliasMapper(); mapper.alias("clazz", Clazz.class, () -> new Clazz()); Clazz ob = new Clazz(); ob.otherValue.set("bar"); Assertions.assertThat(Attrs.toMap(ob, mapper::toName)) .containsEntry("defValue", "foo") .containsEntry("nullValue", null) .containsEntry("otherValue", "bar"); Clazz clazz = Attrs.fromMap(Clazz.class, Attrs.toMap(ob, mapper::toName), mapper::fromName); Assertions.assertThat(clazz.defValue.get()).isEqualTo("foo"); Assertions.assertThat(clazz.nullValue.get()).isNull(); Assertions.assertThat(clazz.otherValue.get()).isEqualTo("bar"); }
public static Builder builder() { return new Builder(); }
AttrString extends Attr<String> { public static Builder builder() { return new Builder(); } }
AttrString extends Attr<String> { public static Builder builder() { return new Builder(); } private  AttrString(
      String value, List<? extends Constraint<? super String>> constraint, String label); }
AttrString extends Attr<String> { public static Builder builder() { return new Builder(); } private  AttrString(
      String value, List<? extends Constraint<? super String>> constraint, String label); static Builder builder(); }
AttrString extends Attr<String> { public static Builder builder() { return new Builder(); } private  AttrString(
      String value, List<? extends Constraint<? super String>> constraint, String label); static Builder builder();  }