Class MethodAccessor<T>

  • Type Parameters:
    T - Method return type

    public class MethodAccessor<T>
    extends java.lang.Object
    Wrapper class for accessing a private method
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodAccessor​(java.lang.String methodName, java.lang.Object owner, java.lang.Class<T> classOfT, java.lang.Class<?>... argumentTypes)
      Create a new MethodAccessor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T call​(java.lang.Object... args)
      Call the method
      T callOrNull​(java.lang.Object... args)
      Call the method, or return NULL if there was an error
      • Methods inherited from class java.lang.Object

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

      • MethodAccessor

        public MethodAccessor​(java.lang.String methodName,
                              java.lang.Object owner,
                              java.lang.Class<T> classOfT,
                              java.lang.Class<?>... argumentTypes)
                       throws java.lang.NoSuchMethodException,
                              java.lang.SecurityException
        Create a new MethodAccessor
        Parameters:
        methodName - Name of private method
        owner - Object to get method from
        classOfT - The class of generic type T
        argumentTypes - The type of every method type in order
        Throws:
        java.lang.NoSuchMethodException
        java.lang.SecurityException
    • Method Detail

      • call

        public T call​(java.lang.Object... args)
               throws java.lang.IllegalAccessException,
                      java.lang.IllegalArgumentException,
                      java.lang.reflect.InvocationTargetException
        Call the method
        Parameters:
        args - Arguments to pass
        Returns:
        Return value
        Throws:
        java.lang.IllegalAccessException
        java.lang.IllegalArgumentException
        java.lang.reflect.InvocationTargetException
      • callOrNull

        public T callOrNull​(java.lang.Object... args)
        Call the method, or return NULL if there was an error
        Parameters:
        args - Arguments to pass
        Returns:
        Return value or NULL