in lightning-core/src/main/java/org/apache/directmemory/lightning/internal/beans/ReflectionPropertyAccessorFactory.java [424:495]
private PropertyAccessor buildForArrayMethod( Method method, Class<?> definedClass )
{
final Method getter = BeanUtil.findGetterMethod( method );
final Method setter = BeanUtil.findSetterMethod( method );
final Method arrayGetter = BeanUtil.findArrayGetterMethod( method );
final Method arraySetter = BeanUtil.findArraySetterMethod( method );
getter.setAccessible( true );
setter.setAccessible( true );
return new MethodArrayPropertyAccessor( setter, getter, definedClass )
{
@Override
public <T> void writeObject( Object instance, T value )
{
try
{
getSetterMethod().invoke( instance, value );
}
catch ( Exception e )
{
throw new IllegalPropertyAccessException( "Exception while writing with method "
+ getSetterMethod().getName(), e );
}
}
@Override
@SuppressWarnings( "unchecked" )
public <T> T readObject( Object instance )
{
try
{
return (T) getGetterMethod().invoke( instance );
}
catch ( Exception e )
{
throw new IllegalPropertyAccessException( "Exception while reading with method "
+ getGetterMethod().getName(), e );
}
}
@Override
public <T> void writeObject( Object instance, int index, T value )
{
try
{
arraySetter.invoke( instance, value, index );
}
catch ( Exception e )
{
throw new IllegalPropertyAccessException( "Exception while writing with method "
+ getSetterMethod().getName(), e );
}
}
@Override
@SuppressWarnings( "unchecked" )
public <T> T readObject( Object instance, int index )
{
try
{
return (T) arrayGetter.invoke( instance, index );
}
catch ( Exception e )
{
throw new IllegalPropertyAccessException( "Exception while reading with method "
+ getGetterMethod().getName(), e );
}
}
};
}