public static Method getterMethodOrNull(Class containerJavaType, String propertyName) { try { return findGetterMethod( containerJavaType, propertyName ); } catch (PropertyNotFoundException e) { return null; } }
public PropertyAccessBasicImpl( PropertyAccessStrategyBasicImpl strategy, Class containerJavaType, final String propertyName) { this.strategy = strategy; final Method getterMethod = ReflectHelper.findGetterMethod( containerJavaType, propertyName ); this.getter = new GetterMethodImpl( containerJavaType, propertyName, getterMethod ); final Method setterMethod = ReflectHelper.findSetterMethod( containerJavaType, propertyName, getterMethod.getReturnType() ); this.setter = new SetterMethodImpl( containerJavaType, propertyName, setterMethod ); }
@Test public void test_getMethod_nestedInterfaces() { assertNotNull( ReflectHelper.findGetterMethod( C.class, "id" ) ); }
@Test public void test_getMethod_superclass() { assertNotNull( ReflectHelper.findGetterMethod( E.class, "id" ) ); }
@TestForIssue(jiraKey = "HHH-12090") @Test public void test_getMethod_nestedInterfaces_on_superclasses() throws InvocationTargetException, IllegalAccessException { Method statusMethodEClass = ReflectHelper.findGetterMethod( E.class, "status" ); assertNotNull(statusMethodEClass); assertEquals( ON, statusMethodEClass.invoke( new E() ) ); Method statusMethodFClass = ReflectHelper.findGetterMethod( F.class, "status" ); assertNotNull(statusMethodFClass); assertEquals( OFF, statusMethodFClass.invoke( new F() ) ); }
@Test @TestForIssue( jiraKey = "HHH-11202") public void testProtectedMethodGetter() throws Exception { final AnEntity entity = new AnEntity( new PK( 1L ) ); final Getter getter = new GetterMethodImpl( AnEntity.class, "pk", ReflectHelper.findGetterMethod( AnEntity.class, "pk" ) ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( getter ); final ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( baos.toByteArray() ) ); final Getter getterClone = (Getter) ois.readObject(); assertSame( getter.get( entity ), getterClone.get( entity ) ); }
@Test @TestForIssue( jiraKey = "HHH-11202") public void testProtectedMethodSetter() throws Exception { final AnEntity entity = new AnEntity( new PK( 1L ) ); final Getter getter = new GetterMethodImpl( AnEntity.class, "pk", ReflectHelper.findGetterMethod( AnEntity.class, "pk" ) ); final Setter setter = new SetterMethodImpl( AnEntity.class, "pk", ReflectHelper.findSetterMethod( AnEntity.class, "pk", PK.class ) ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( setter ); final ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( baos.toByteArray() ) ); final Setter setterClone = (Setter) ois.readObject(); final PK pkNew = new PK( 2L ); setterClone.set( entity, pkNew, null ); assertSame( pkNew, getter.get( entity ) ); } }
public static Method getterMethodOrNull(Class containerJavaType, String propertyName) { try { return findGetterMethod( containerJavaType, propertyName ); } catch (PropertyNotFoundException e) { return null; } }
public PropertyAccessBasicImpl( PropertyAccessStrategyBasicImpl strategy, Class containerJavaType, final String propertyName) { this.strategy = strategy; final Method getterMethod = ReflectHelper.findGetterMethod( containerJavaType, propertyName ); this.getter = new GetterMethodImpl( containerJavaType, propertyName, getterMethod ); final Method setterMethod = ReflectHelper.findSetterMethod( containerJavaType, propertyName, getterMethod.getReturnType() ); this.setter = new SetterMethodImpl( containerJavaType, propertyName, setterMethod ); }