@Test public void shouldFoundASetter() throws Exception { final House aSimpleJavaBeans = new House(); final List<Method> methodsOfHouseClass = Arrays.asList(House.class.getMethods()); Method foundMethod = new ReflectionBasedNullHandler(proxifier).findSetter(aSimpleJavaBeans, "Mouse", Mouse.class); assertThat(methodsOfHouseClass, hasItem(foundMethod)); assertThat(foundMethod.toGenericString(), startsWith("public void ")); assertThat(foundMethod.getName(), is(startsWith("setMouse"))); }
Method findSetter(Object target, String propertyCapitalized, Class<? extends Object> argument) { Class<? extends Object> targetClass = target.getClass(); if (proxifier.isProxy(target)) { targetClass = targetClass.getSuperclass(); } return new Mirror().on(targetClass).reflect().method("set" + propertyCapitalized).withArgs(argument); }
ReflectionBasedNullHandler extends ObjectNullHandler { Method findSetter(Object target, String propertyCapitalized, Class<? extends Object> argument) { Class<? extends Object> targetClass = target.getClass(); if (proxifier.isProxy(target)) { targetClass = targetClass.getSuperclass(); } return new Mirror().on(targetClass).reflect().method("set" + propertyCapitalized).withArgs(argument); } }
ReflectionBasedNullHandler extends ObjectNullHandler { Method findSetter(Object target, String propertyCapitalized, Class<? extends Object> argument) { Class<? extends Object> targetClass = target.getClass(); if (proxifier.isProxy(target)) { targetClass = targetClass.getSuperclass(); } return new Mirror().on(targetClass).reflect().method("set" + propertyCapitalized).withArgs(argument); } ReflectionBasedNullHandler(Proxifier proxifier); }
ReflectionBasedNullHandler extends ObjectNullHandler { Method findSetter(Object target, String propertyCapitalized, Class<? extends Object> argument) { Class<? extends Object> targetClass = target.getClass(); if (proxifier.isProxy(target)) { targetClass = targetClass.getSuperclass(); } return new Mirror().on(targetClass).reflect().method("set" + propertyCapitalized).withArgs(argument); } ReflectionBasedNullHandler(Proxifier proxifier); @Override Object nullPropertyValue(Map context, Object target, Object property); }
ReflectionBasedNullHandler extends ObjectNullHandler { Method findSetter(Object target, String propertyCapitalized, Class<? extends Object> argument) { Class<? extends Object> targetClass = target.getClass(); if (proxifier.isProxy(target)) { targetClass = targetClass.getSuperclass(); } return new Mirror().on(targetClass).reflect().method("set" + propertyCapitalized).withArgs(argument); } ReflectionBasedNullHandler(Proxifier proxifier); @Override Object nullPropertyValue(Map context, Object target, Object property);  }