Class ExecutableUtils

  • All Implemented Interfaces:
    Utils

    public abstract class ExecutableUtils
    extends java.lang.Object
    implements Utils
    The utility class for Java Reflection Executable
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    Executable
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <E extends java.lang.reflect.Executable & java.lang.reflect.Member>
      void
      execute​(E object, ThrowableConsumer<E> callback)
      Execute an Executable instance
      static <E extends java.lang.reflect.Executable & java.lang.reflect.Member,​R>
      R
      execute​(E executableMember, ThrowableFunction<E,​R> callback)
      Execute an Executable instance
      static <E extends java.lang.reflect.Executable & java.lang.reflect.Member,​R>
      R
      execute​(E executable, ThrowableSupplier<R> supplier)
      Executes the Executable
      • Methods inherited from class java.lang.Object

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

      • execute

        public static <E extends java.lang.reflect.Executable & java.lang.reflect.Member> void execute​(E object,
                                                                                                       ThrowableConsumer<E> callback)
                                                                                                throws java.lang.NullPointerException,
                                                                                                       java.lang.IllegalStateException,
                                                                                                       java.lang.IllegalArgumentException,
                                                                                                       java.lang.RuntimeException
        Execute an Executable instance
        Type Parameters:
        E - The type or subtype of Executable
        Parameters:
        object - Executable instance, Field, Method or Constructor
        callback - the call back to execute Executable object
        Throws:
        java.lang.NullPointerException - If executableMember is null
        java.lang.IllegalStateException - if this executableMember object is enforcing Java language access control and the underlying executable member is inaccessible.
        java.lang.IllegalArgumentException - if the executable member is an instance executable member and the specified object argument is not an instance of the class or interface declaring the underlying executable member (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a executable member invocation conversion.
        java.lang.RuntimeException - if the underlying executable member throws an exception.
      • execute

        public static <E extends java.lang.reflect.Executable & java.lang.reflect.Member,​R> R execute​(E executable,
                                                                                                            ThrowableSupplier<R> supplier)
                                                                                                     throws java.lang.NullPointerException,
                                                                                                            java.lang.IllegalStateException,
                                                                                                            java.lang.IllegalArgumentException,
                                                                                                            java.lang.RuntimeException
        Executes the Executable
        Parameters:
        executable - Executable
        supplier - ThrowableConsumer
        Throws:
        java.lang.NullPointerException - If executableMember is null
        java.lang.IllegalStateException - if this executableMember object is enforcing Java language access control and the underlying executable member is inaccessible.
        java.lang.IllegalArgumentException - if the executable member is an instance executable member and the specified object argument is not an instance of the class or interface declaring the underlying executable member (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a executable member invocation conversion.
        java.lang.RuntimeException - if the underlying executable member throws an exception.
      • execute

        public static <E extends java.lang.reflect.Executable & java.lang.reflect.Member,​R> R execute​(E executableMember,
                                                                                                            ThrowableFunction<E,​R> callback)
                                                                                                     throws java.lang.NullPointerException,
                                                                                                            java.lang.IllegalStateException,
                                                                                                            java.lang.IllegalArgumentException,
                                                                                                            java.lang.RuntimeException
        Execute an Executable instance
        Type Parameters:
        E - The type or subtype of Executable
        R - The type of execution result
        Parameters:
        executableMember - Executable Member, Method or Constructor
        callback - the call back to execute Executable Member
        Returns:
        The execution result
        Throws:
        java.lang.NullPointerException - If executableMember is null
        java.lang.IllegalStateException - if this executableMember object is enforcing Java language access control and the underlying executable member is inaccessible.
        java.lang.IllegalArgumentException - if the executable member is an instance executable member and the specified object argument is not an instance of the class or interface declaring the underlying executable member (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a executable member invocation conversion.
        java.lang.RuntimeException - if the underlying executable member throws an exception.