@Test public void testEmptyPropertyReturnsInvalidObject() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage(containsString(TestEnum.class.getName())); thrown.expectMessage(containsString(TestInterface.class.getName())); thrown.expectMessage(containsString("cannot be assigned to")); BuilderDynaBean builderDynaBean = new BuilderDynaBean(TestInterface.class, convertUtilsBean, s -> TestEnum.Green); utilsBean.setProperty(builderDynaBean, "", "test"); builderDynaBean.build(TestInterface.class); }
@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);  }