protected static Field fieldOrNull(Class containerJavaType, String propertyName) { try { return ReflectHelper.findField( containerJavaType, propertyName ); } catch (PropertyNotFoundException e) { return null; } }
public PropertyAccessFieldImpl( PropertyAccessStrategyFieldImpl strategy, Class containerJavaType, final String propertyName) { this.strategy = strategy; final Field field = ReflectHelper.findField( containerJavaType, propertyName ); this.getter = new GetterFieldImpl( containerJavaType, propertyName, field ); this.setter = new SetterFieldImpl( containerJavaType, propertyName, field ); }
@Before public void setUp() throws Exception { ssr = new StandardServiceRegistryBuilder().build(); simpleValueAttributeConverterDescriptorField = ReflectHelper.findField( SimpleValue.class, "attributeConverterDescriptor" ); }
@Test @TestForIssue( jiraKey = "HHH-11202") public void testPrivateFieldGetter() throws Exception { final AnEntity entity = new AnEntity( new PK( 1L ) ); final String propertyName = "pk"; final Getter getter = new GetterFieldImpl( AnEntity.class, propertyName, ReflectHelper.findField( AnEntity.class, propertyName) ); 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 testPrivateFieldSetter() throws Exception { AnEntity entity = new AnEntity( new PK( 1L ) ); final String propertyName = "pk"; final Getter getter = new GetterFieldImpl( AnEntity.class, propertyName, ReflectHelper.findField( AnEntity.class, propertyName) ); final Setter setter = new SetterFieldImpl( AnEntity.class, propertyName, ReflectHelper.findField( AnEntity.class, propertyName) ); 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 ) ); }
protected static Field fieldOrNull(Class containerJavaType, String propertyName) { try { return ReflectHelper.findField( containerJavaType, propertyName ); } catch (PropertyNotFoundException e) { return null; } }
public PropertyAccessFieldImpl( PropertyAccessStrategyFieldImpl strategy, Class containerJavaType, final String propertyName) { this.strategy = strategy; final Field field = ReflectHelper.findField( containerJavaType, propertyName ); this.getter = new GetterFieldImpl( containerJavaType, propertyName, field ); this.setter = new SetterFieldImpl( containerJavaType, propertyName, field ); }