private PropertyAccessor buildForValueMethod()

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


    private PropertyAccessor buildForValueMethod( Method method, Class<?> definedClass )
    {
        Method getter = BeanUtil.findGetterMethod( method );
        Method setter = BeanUtil.findSetterMethod( method );

        getter.setAccessible( true );
        setter.setAccessible( true );

        return new MethodValuePropertyAccessor( 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 );
                }
            }
        };
    }