Class Accessible


  • public class Accessible
    extends java.lang.Object
    Utility class to decorate routine code of accessing fields and methods in complex objects. Supports access to private elements and inheritance.
    • Constructor Summary

      Constructors 
      Constructor Description
      Accessible​(java.lang.Object object)
      Create the decorator for given object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AccessibleField field​(java.lang.reflect.Field f)
      Create a decorator for an instance of accessible field.
      AccessibleField field​(java.lang.String name)
      Create a decorator for an instance of accessible field.
      AccessibleMethod method​(java.lang.reflect.Method m)
      Create a decorator for an instance of accessible method.
      AccessibleMethod method​(java.lang.String m, java.lang.Class<?>... parameterTypes)
      Create a decorator for an instance of accessible method.
      static Accessible on​(java.lang.Object object)
      Create the decorator for given object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Accessible

        public Accessible​(@Nonnull
                          java.lang.Object object)
        Create the decorator for given object.
        Parameters:
        object - an instance of object on which you need reflective access
    • Method Detail

      • method

        @Nonnull
        public AccessibleMethod method​(@Nonnull
                                       java.lang.reflect.Method m)
        Create a decorator for an instance of accessible method.
        Parameters:
        m - method to access
        Returns:
        decorator instance
      • method

        @Nonnull
        public AccessibleMethod method​(@Nonnull
                                       java.lang.String m,
                                       @Nullable
                                       java.lang.Class<?>... parameterTypes)
                                throws java.lang.NoSuchMethodException
        Create a decorator for an instance of accessible method.
        Parameters:
        m - method to access
        parameterTypes - an array of specific parameters to distinguish the method
        Returns:
        decorator instance
        Throws:
        java.lang.NoSuchMethodException - no method with such name found
      • field

        @Nonnull
        public AccessibleField field​(@Nonnull
                                     java.lang.reflect.Field f)
        Create a decorator for an instance of accessible field.
        Parameters:
        f - field to access
        Returns:
        decorator instance
      • field

        @Nonnull
        public AccessibleField field​(@Nonnull
                                     java.lang.String name)
                              throws java.lang.NoSuchFieldException
        Create a decorator for an instance of accessible field.
        Parameters:
        name - field to access
        Returns:
        decorator instance
        Throws:
        java.lang.NoSuchFieldException - no field with such name found
      • on

        @Nonnull
        public static Accessible on​(@Nonnull
                                    java.lang.Object object)
        Create the decorator for given object.
        Parameters:
        object - an instance of object on which you need reflective access
        Returns:
        decorator instance