Class AbstractExecutor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AbstractExecutor.Get
      Abstract class that is used to execute an arbitrary 'get' method.
      static class  AbstractExecutor.Method
      Abstract class that is used to execute an arbitrary method.
      static class  AbstractExecutor.Set
      Abstract class that is used to execute an arbitrary 'set' method.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.reflect.Method method
      Method to be executed.
      protected java.lang.Class<?> objectClass
      The class this executor applies to.
      static java.lang.Object TRY_FAILED
      A marker for invocation failures in tryInvoke.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractExecutor​(java.lang.Class<?> theClass, java.lang.reflect.Method theMethod)
      Default and sole constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.Integer castInteger​(java.lang.Object arg)
      Coerce an Object which must be a number to an Integer.
      (package private) static java.lang.String castString​(java.lang.Object arg)
      Coerce an Object to a String.
      (package private) static java.lang.Class<?> classOf​(java.lang.Object instance)
      Gets the class of an object or Object if null.
      boolean equals​(java.lang.Object obj)  
      boolean equals​(AbstractExecutor arg)
      Indicates whether some other executor is equivalent to this one.
      java.lang.reflect.Method getMethod()
      Gets the method to be executed or used as a marker.
      java.lang.String getMethodName()
      Gets the method name used.
      java.lang.Class<?> getTargetClass()
      Gets the object class targeted by this executor.
      java.lang.Object getTargetProperty()
      Gets the property targeted by this executor.
      int hashCode()  
      (package private) static java.lang.reflect.Method initMarker​(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>... parms)
      A helper to initialize the marker methods (array.get, list.get, etc...).
      boolean isAlive()
      Tell whether the executor is alive by looking at the value of the method.
      boolean isCacheable()
      Specifies if this executor is cacheable and able to be reused for this class of object it was returned for.
      (package private) static java.lang.Object[] makeArgs​(java.lang.Object... args)
      Creates an arguments array.
      boolean tryFailed​(java.lang.Object exec)
      Checks whether a tryExecute failed or not.
      • Methods inherited from class java.lang.Object

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

      • TRY_FAILED

        public static final java.lang.Object TRY_FAILED
        A marker for invocation failures in tryInvoke.
      • objectClass

        protected final java.lang.Class<?> objectClass
        The class this executor applies to.
      • method

        protected final java.lang.reflect.Method method
        Method to be executed.
    • Constructor Detail

      • AbstractExecutor

        protected AbstractExecutor​(java.lang.Class<?> theClass,
                                   java.lang.reflect.Method theMethod)
        Default and sole constructor.
        Parameters:
        theClass - the class this executor applies to
        theMethod - the method held by this executor
    • Method Detail

      • castInteger

        static java.lang.Integer castInteger​(java.lang.Object arg)
        Coerce an Object which must be a number to an Integer.
        Parameters:
        arg - the Object to coerce
        Returns:
        an Integer if it can be converted, null otherwise
      • castString

        static java.lang.String castString​(java.lang.Object arg)
        Coerce an Object to a String.
        Parameters:
        arg - the Object to coerce
        Returns:
        a String if it can be converted, null otherwise
      • classOf

        static java.lang.Class<?> classOf​(java.lang.Object instance)
        Gets the class of an object or Object if null.
        Parameters:
        instance - the instance
        Returns:
        the class
      • initMarker

        static java.lang.reflect.Method initMarker​(java.lang.Class<?> clazz,
                                                   java.lang.String name,
                                                   java.lang.Class<?>... parms)
        A helper to initialize the marker methods (array.get, list.get, etc...).
        Parameters:
        clazz - the class to introspect
        name - the name of the method
        parms - the parameters
        Returns:
        the method
      • makeArgs

        static java.lang.Object[] makeArgs​(java.lang.Object... args)
        Creates an arguments array.
        Parameters:
        args - the list of arguments
        Returns:
        the arguments array
      • equals

        public boolean equals​(AbstractExecutor arg)
        Indicates whether some other executor is equivalent to this one.
        Parameters:
        arg - the other executor to check
        Returns:
        true if both executors are equivalent, false otherwise
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getMethod

        public final java.lang.reflect.Method getMethod()
        Gets the method to be executed or used as a marker.
        Returns:
        Method The method used by execute in derived classes.
      • getMethodName

        public final java.lang.String getMethodName()
        Gets the method name used.
        Returns:
        method name
      • getTargetClass

        public final java.lang.Class<?> getTargetClass()
        Gets the object class targeted by this executor.
        Returns:
        the target object class
      • getTargetProperty

        public java.lang.Object getTargetProperty()
        Gets the property targeted by this executor.
        Returns:
        the target property
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isAlive

        public final boolean isAlive()
        Tell whether the executor is alive by looking at the value of the method.
        Returns:
        boolean Whether the executor is alive.
      • isCacheable

        public boolean isCacheable()
        Specifies if this executor is cacheable and able to be reused for this class of object it was returned for.
        Returns:
        true if can be reused for this class, false if not
      • tryFailed

        public final boolean tryFailed​(java.lang.Object exec)
        Checks whether a tryExecute failed or not.
        Parameters:
        exec - the value returned by tryExecute
        Returns:
        true if tryExecute failed, false otherwise