private PropertyAccessor buildForArrayField()

in lightning-core/src/main/java/org/apache/directmemory/lightning/internal/beans/ReflectionPropertyAccessorFactory.java [92:380]


    private PropertyAccessor buildForArrayField( final Field field, final Class<?> definedClass )
    {
        field.setAccessible( true );
        return new FieldArrayPropertyAccessor( field, definedClass )
        {

            @Override
            public <T> void writeObject( Object instance, T value )
            {
                try
                {
                    getField().set( instance, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while writing field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            @SuppressWarnings( "unchecked" )
            public <T> T readObject( Object instance )
            {
                try
                {
                    return (T) getField().get( instance );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public <T> void writeObject( Object instance, int index, T value )
            {
                try
                {
                    Array.set( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while writing field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            @SuppressWarnings( "unchecked" )
            public <T> T readObject( Object instance, int index )
            {
                try
                {
                    return (T) Array.get( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeShort( Object instance, int index, short value )
            {
                try
                {
                    Array.setShort( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeLong( Object instance, int index, long value )
            {
                try
                {
                    Array.setLong( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeInt( Object instance, int index, int value )
            {
                try
                {
                    Array.setInt( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeFloat( Object instance, int index, float value )
            {
                try
                {
                    Array.setFloat( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeDouble( Object instance, int index, double value )
            {
                try
                {
                    Array.setDouble( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeChar( Object instance, int index, char value )
            {
                try
                {
                    Array.setChar( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeByte( Object instance, int index, byte value )
            {
                try
                {
                    Array.setByte( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public void writeBoolean( Object instance, int index, boolean value )
            {
                try
                {
                    Array.setBoolean( instance, index, value );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public short readShort( Object instance, int index )
            {
                try
                {
                    return Array.getShort( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public long readLong( Object instance, int index )
            {
                try
                {
                    return Array.getLong( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public int readInt( Object instance, int index )
            {
                try
                {
                    return Array.getInt( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public float readFloat( Object instance, int index )
            {
                try
                {
                    return Array.getFloat( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public double readDouble( Object instance, int index )
            {
                try
                {
                    return Array.getDouble( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public char readChar( Object instance, int index )
            {
                try
                {
                    return Array.getChar( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public byte readByte( Object instance, int index )
            {
                try
                {
                    return Array.getByte( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }

            @Override
            public boolean readBoolean( Object instance, int index )
            {
                try
                {
                    return Array.getBoolean( instance, index );
                }
                catch ( Exception e )
                {
                    throw new IllegalPropertyAccessException( "Exception while reading field " + getField().getName(),
                                                              e );
                }
            }
        };
    }