@Test public void testComplexArrayValuesBuilder() throws Exception { TestVariantBuilder variant1 = TestVariantBuilder.builder().variantBuilderName("variant-1") .testEnum(TestEnum.Green).intClass(10).build(); TestVariantBuilder variant2 = TestVariantBuilder.builder().variantBuilderName("variant-2") .testEnum(TestEnum.Blue).intClass(20).build(); ComplexArrayClassVariant expected = ComplexArrayClassVariant.builder().variantName("complex-test") .tests(new TestInterface[] { variant1, variant2 }).build(); BuilderDynaBean builderDynaBean = new BuilderDynaBean(ComplexArrayClassVariant.class, convertUtilsBean); utilsBean.setProperty(builderDynaBean, "variantName", expected.variantName); utilsBean.setProperty(builderDynaBean, "tests[0].class", TestVariantBuilder.class.getName()); utilsBean.setProperty(builderDynaBean, "tests[0].variantBuilderName", variant1.variantBuilderName); utilsBean.setProperty(builderDynaBean, "tests[0].intClass", variant1.intClass); utilsBean.setProperty(builderDynaBean, "tests[0].testEnum", variant1.testEnum); utilsBean.setProperty(builderDynaBean, "tests[1].class", TestVariantBuilder.class.getName()); utilsBean.setProperty(builderDynaBean, "tests[1].variantBuilderName", variant2.variantBuilderName); utilsBean.setProperty(builderDynaBean, "tests[1].intClass", variant2.intClass); utilsBean.setProperty(builderDynaBean, "tests[1].testEnum", variant2.testEnum); ComplexArrayClassVariant actual = builderDynaBean.build(ComplexArrayClassVariant.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);  }