@Test public void testComplexRootAllParameters() throws Exception { TestSimpleBuilder simpleBuilder = TestSimpleBuilder.builder().stringL1("simple-l1").longVal(20L).build(); TestRootClass expected = TestRootClass.builder().intVal(10).stringVal("root").testEnum(TestEnum.Red) .testComplexCreate(TestComplexCreate.create("real", TestSimpleBuilder.builder().stringL1("complex-l1").longVal(10L).build())) .testSimpleBuilder(simpleBuilder).testSimpleCreate(TestSimpleCreate.create("first", "last")).build(); BuilderDynaBean builderDynaBean = new BuilderDynaBean(TestRootClass.class, convertUtilsBean); utilsBean.setProperty(builderDynaBean, "intVal", expected.intVal); utilsBean.setProperty(builderDynaBean, "stringVal", expected.stringVal); utilsBean.setProperty(builderDynaBean, "testEnum", expected.testEnum); utilsBean.setProperty(builderDynaBean, "testComplexCreate.[0]", expected.testComplexCreate.realName); utilsBean.setProperty(builderDynaBean, "testComplexCreate.[1].stringL1", expected.testComplexCreate.test1.stringL1); utilsBean.setProperty(builderDynaBean, "testComplexCreate.[1].longVal", expected.testComplexCreate.test1.longVal); utilsBean.setProperty(builderDynaBean, "testSimpleBuilder.class", TestSimpleBuilder.class.getName()); utilsBean.setProperty(builderDynaBean, "testSimpleBuilder.stringL1", simpleBuilder.stringL1); utilsBean.setProperty(builderDynaBean, "testSimpleBuilder.longVal", simpleBuilder.longVal); utilsBean.setProperty(builderDynaBean, "testSimpleCreate.[0]", expected.testSimpleCreate.firstName); utilsBean.setProperty(builderDynaBean, "testSimpleCreate.[1]", expected.testSimpleCreate.lastName); TestRootClass actual = builderDynaBean.build(TestRootClass.class); assertThat(actual, equalTo(expected)); }
@SafeVarargs public final <T> T build(Class<T> expected, Function<Object, Object>... additionalMutators) { if (emptyPropertyResolved != null) { validatedExpectedClass(emptyPropertyResolved.getClass(), expected); return expected.cast(emptyPropertyResolved); } if (dynaBeanBuilderSupport == null && dynaBeanCreateSupport == null) { return null; } validatedExpectedClass(destinedClass, expected); if (dynaBeanBuilderSupport.isValid()) { return expected.cast(dynaBeanBuilderSupport.build(additionalMutators)); } else { return expected.cast(dynaBeanCreateSupport.build()); } }
BuilderDynaBean implements DynaBean { @SafeVarargs public final <T> T build(Class<T> expected, Function<Object, Object>... additionalMutators) { if (emptyPropertyResolved != null) { validatedExpectedClass(emptyPropertyResolved.getClass(), expected); return expected.cast(emptyPropertyResolved); } if (dynaBeanBuilderSupport == null && dynaBeanCreateSupport == null) { return null; } validatedExpectedClass(destinedClass, expected); if (dynaBeanBuilderSupport.isValid()) { return expected.cast(dynaBeanBuilderSupport.build(additionalMutators)); } else { return expected.cast(dynaBeanCreateSupport.build()); } } }
BuilderDynaBean implements DynaBean { @SafeVarargs public final <T> T build(Class<T> expected, Function<Object, Object>... additionalMutators) { if (emptyPropertyResolved != null) { validatedExpectedClass(emptyPropertyResolved.getClass(), expected); return expected.cast(emptyPropertyResolved); } if (dynaBeanBuilderSupport == null && dynaBeanCreateSupport == null) { return null; } validatedExpectedClass(destinedClass, expected); if (dynaBeanBuilderSupport.isValid()) { return expected.cast(dynaBeanBuilderSupport.build(additionalMutators)); } else { return expected.cast(dynaBeanCreateSupport.build()); } } BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean, String... classPrefixSearchList);  BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean,
            Function<String, ?> emptyPropertyHandler, String... classPrefixSearchList);  BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean,
            Function<String, ?> emtpyPropertyHandler, List<String> classPrefixSearchList); }
BuilderDynaBean implements DynaBean { @SafeVarargs public final <T> T build(Class<T> expected, Function<Object, Object>... additionalMutators) { if (emptyPropertyResolved != null) { validatedExpectedClass(emptyPropertyResolved.getClass(), expected); return expected.cast(emptyPropertyResolved); } if (dynaBeanBuilderSupport == null && dynaBeanCreateSupport == null) { return null; } validatedExpectedClass(destinedClass, expected); if (dynaBeanBuilderSupport.isValid()) { return expected.cast(dynaBeanBuilderSupport.build(additionalMutators)); } else { return expected.cast(dynaBeanCreateSupport.build()); } } BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean, String... classPrefixSearchList);  BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean,
            Function<String, ?> emptyPropertyHandler, String... classPrefixSearchList);  BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean,
            Function<String, ?> emtpyPropertyHandler, List<String> classPrefixSearchList); boolean canBuildOrCreate(); @SafeVarargs final T build(Class<T> expected, Function<Object, Object>... additionalMutators); @Override boolean contains(String name, String key); @Override Object get(String name); @Override Object get(String name, int index); @Override Object get(String name, String key); @Override DynaClass getDynaClass(); @Override void remove(String name, String key); @Override void set(String name, Object value); @Override void set(String name, int index, Object value); @Override void set(String name, String key, Object value); }
BuilderDynaBean implements DynaBean { @SafeVarargs public final <T> T build(Class<T> expected, Function<Object, Object>... additionalMutators) { if (emptyPropertyResolved != null) { validatedExpectedClass(emptyPropertyResolved.getClass(), expected); return expected.cast(emptyPropertyResolved); } if (dynaBeanBuilderSupport == null && dynaBeanCreateSupport == null) { return null; } validatedExpectedClass(destinedClass, expected); if (dynaBeanBuilderSupport.isValid()) { return expected.cast(dynaBeanBuilderSupport.build(additionalMutators)); } else { return expected.cast(dynaBeanCreateSupport.build()); } } BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean, String... classPrefixSearchList);  BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean,
            Function<String, ?> emptyPropertyHandler, String... classPrefixSearchList);  BuilderDynaBean(Class<?> destinedClass, ConvertUtilsBean convertUtilsBean,
            Function<String, ?> emtpyPropertyHandler, List<String> classPrefixSearchList); boolean canBuildOrCreate(); @SafeVarargs final T build(Class<T> expected, Function<Object, Object>... additionalMutators); @Override boolean contains(String name, String key); @Override Object get(String name); @Override Object get(String name, int index); @Override Object get(String name, String key); @Override DynaClass getDynaClass(); @Override void remove(String name, String key); @Override void set(String name, Object value); @Override void set(String name, int index, Object value); @Override void set(String name, String key, Object value);  }