@Test public void testObjectAttr() { class Foo extends AttrComposite {} @SuppressWarnings("unused") class Clazz extends AttrComposite { AttrObject<Foo> attr = attributes.register("attr", AttrObject.builder(Foo.class).defaultValue(Foo::new)); AttrObject<Foo> attrNull = attributes.register("attrNull", AttrObject.builder(Foo.class).defaultValue(() -> null)); } ClassInfoCollector collector = new ClassInfoCollector(JvmNameMapper.INSTANCE); ClassInfo classInfo = collector.collect(new Clazz()); Assertions.assertThat(classInfo.attributes) .hasEntrySatisfying( "attr", info -> Assertions.assertThat(info.value) .isEqualTo(JvmNameMapper.INSTANCE.toName(new Foo()))) .hasEntrySatisfying("attrNull", info -> Assertions.assertThat(info.value).isNull()); }
public ClassInfo collect(AcceptingVisitor c) { return collected.computeIfAbsent( c.getClass(), (key) -> { final ClassInfo ci = new ClassInfo(); ci.clazz = c.getClass(); ci.name = aliasMapper.toName(c); ci.type = getQualifiedName(c.getClass()); c.accept(new AttrInfoCollector(ci.attributes, aliasMapper)); return ci; }); }
ClassInfoCollector { public ClassInfo collect(AcceptingVisitor c) { return collected.computeIfAbsent( c.getClass(), (key) -> { final ClassInfo ci = new ClassInfo(); ci.clazz = c.getClass(); ci.name = aliasMapper.toName(c); ci.type = getQualifiedName(c.getClass()); c.accept(new AttrInfoCollector(ci.attributes, aliasMapper)); return ci; }); } }
ClassInfoCollector { public ClassInfo collect(AcceptingVisitor c) { return collected.computeIfAbsent( c.getClass(), (key) -> { final ClassInfo ci = new ClassInfo(); ci.clazz = c.getClass(); ci.name = aliasMapper.toName(c); ci.type = getQualifiedName(c.getClass()); c.accept(new AttrInfoCollector(ci.attributes, aliasMapper)); return ci; }); } ClassInfoCollector(ClassNameMapper aliasMapper); }
ClassInfoCollector { public ClassInfo collect(AcceptingVisitor c) { return collected.computeIfAbsent( c.getClass(), (key) -> { final ClassInfo ci = new ClassInfo(); ci.clazz = c.getClass(); ci.name = aliasMapper.toName(c); ci.type = getQualifiedName(c.getClass()); c.accept(new AttrInfoCollector(ci.attributes, aliasMapper)); return ci; }); } ClassInfoCollector(ClassNameMapper aliasMapper); ClassInfo collect(AcceptingVisitor c); static String getQualifiedName(Class<?> clazz); }
ClassInfoCollector { public ClassInfo collect(AcceptingVisitor c) { return collected.computeIfAbsent( c.getClass(), (key) -> { final ClassInfo ci = new ClassInfo(); ci.clazz = c.getClass(); ci.name = aliasMapper.toName(c); ci.type = getQualifiedName(c.getClass()); c.accept(new AttrInfoCollector(ci.attributes, aliasMapper)); return ci; }); } ClassInfoCollector(ClassNameMapper aliasMapper); ClassInfo collect(AcceptingVisitor c); static String getQualifiedName(Class<?> clazz);  }