Class ReflectedMethod


  • public class ReflectedMethod
    extends java.lang.Object
    ReflectedMethod. Encapsulates a method that may or may not exist on some receiver. Invocation policy is that if the method can be invoked, it is. On failure, returns null.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Method method  
      private java.lang.Object subject  
    • Constructor Summary

      Constructors 
      Constructor Description
      ReflectedMethod​(java.lang.Object subject, java.lang.String methodName, java.lang.Class[] paramTypes)
      Constructor ReflectedMethod.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean exists()
      Method exists.
      java.lang.Class getType()
      Method getType.
      java.lang.Object invoke​(java.lang.Object[] params)
      Method invoke.
      • Methods inherited from class java.lang.Object

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

      • subject

        private java.lang.Object subject
      • method

        private java.lang.reflect.Method method
    • Constructor Detail

      • ReflectedMethod

        public ReflectedMethod​(java.lang.Object subject,
                               java.lang.String methodName,
                               java.lang.Class[] paramTypes)
        Constructor ReflectedMethod. Create a ReflectedMethod object.
        Parameters:
        subject - The object on which the method lives.
        methodName - The name of the method.
        paramTypes - The method's parameter types.
    • Method Detail

      • exists

        public boolean exists()
        Method exists. Returns true if the underlying method exists, false otherwise.
        Returns:
        true if the underlying method exists, false otherwise.
      • invoke

        public java.lang.Object invoke​(java.lang.Object[] params)
        Method invoke. If possible, invoke the encapsulated method with the specified parameters.
        Parameters:
        params - An Object[] containing the parameters to pass.
        Returns:
        any return value or null if there was no return value or an error occured.
      • getType

        public java.lang.Class getType()
        Method getType. Returns the return type of the method.
        Returns:
        The return type or null if none.