Class ReflectionMethod

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object execute​(@NotNull java.lang.Object instance, @NotNull java.lang.reflect.Method method)
      Execute method with no arguments.
      static java.lang.Object execute​(@NotNull java.lang.Object instance, @NotNull java.lang.reflect.Method method, @NotNull Arguments args)
      Execute method with arguments.
      static <O> O execute​(@NotNull java.lang.Object instance, @NotNull java.lang.reflect.Method method, @NotNull java.lang.Class<O> outputType, @NotNull Arguments arguments)  
      static <I,​O>
      O
      execute​(@NotNull java.lang.Object instance, @NotNull java.lang.reflect.Method method, @NotNull java.lang.Class<O> outputType, @NotNull java.lang.Class<I> argClass, I argValue)
      Execute method from object instance by only one param.
      static <O> O execute​(@NotNull java.lang.Object instance, @NotNull java.lang.reflect.Method method, java.lang.Object... args)  
      static <T> T executeStatic​(@NotNull java.lang.Class<?> declareCls, @NotNull java.lang.Class<T> outputCls, @NotNull java.lang.String methodName, java.lang.Object... args)
      Execute static method
      static java.util.List<java.lang.reflect.Method> find​(@NotNull java.lang.Class<?> clazz, java.util.function.Predicate<java.lang.reflect.Method> predicate)
      Find declared methods in given class that matches with filter
      static java.util.stream.Stream<java.lang.reflect.Method> find​(java.util.function.Predicate<java.lang.reflect.Method> predicate, @NotNull java.lang.Class<?> clazz)  
      static boolean validateMethod​(@NotNull java.lang.reflect.Method method, @NotNull java.lang.Class<?> outputType, @NotNull Arguments arguments)
      Check given Method is matched with given output class and inputs class
      static boolean validateMethod​(@NotNull java.lang.reflect.Method method, @NotNull java.lang.Class<?> outputType, @NotNull java.util.Collection<java.lang.Class<?>> argClasses)
      Check given Method is matched with given output class and inputs class
      static boolean validateMethod​(java.lang.reflect.Method method, java.lang.Class<?> outputType, java.lang.Class<?>... argClasses)
      Check given Method is matched with given output class and inputs class
      • Methods inherited from class java.lang.Object

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

      • executeStatic

        public static <T> T executeStatic​(@NotNull
                                          @NotNull java.lang.Class<?> declareCls,
                                          @NotNull
                                          @NotNull java.lang.Class<T> outputCls,
                                          @NotNull
                                          @NotNull java.lang.String methodName,
                                          java.lang.Object... args)
        Execute static method
        Type Parameters:
        T - Type of output
        Parameters:
        declareCls - a declare class
        outputCls - an output class
        methodName - a method name
        args - a object arguments
        Returns:
        method result
      • execute

        public static java.lang.Object execute​(@NotNull
                                               @NotNull java.lang.Object instance,
                                               @NotNull
                                               @NotNull java.lang.reflect.Method method)
        Execute method with no arguments.
        Parameters:
        instance - an object instance
        method - a method to execute
        Returns:
        the method result
      • execute

        public static java.lang.Object execute​(@NotNull
                                               @NotNull java.lang.Object instance,
                                               @NotNull
                                               @NotNull java.lang.reflect.Method method,
                                               @NotNull
                                               @NotNull Arguments args)
        Execute method with arguments.
        Parameters:
        instance - an object instance
        method - a method to execute
        Returns:
        the method result
      • execute

        public static <O> O execute​(@NotNull
                                    @NotNull java.lang.Object instance,
                                    @NotNull
                                    @NotNull java.lang.reflect.Method method,
                                    java.lang.Object... args)
      • execute

        public static <I,​O> O execute​(@NotNull
                                            @NotNull java.lang.Object instance,
                                            @NotNull
                                            @NotNull java.lang.reflect.Method method,
                                            @NotNull
                                            @NotNull java.lang.Class<O> outputType,
                                            @NotNull
                                            @NotNull java.lang.Class<I> argClass,
                                            I argValue)
        Execute method from object instance by only one param.
        Type Parameters:
        I - Type of Input parameter
        O - Type of Return result
        Parameters:
        instance - Object instance
        method - Method to execute
        outputType - Output type of method
        argClass - Param type of method
        argValue - Argument to pass into method
        Returns:
        the method result
        Throws:
        ReflectionException - if any error when invoke method
      • execute

        public static <O> O execute​(@NotNull
                                    @NotNull java.lang.Object instance,
                                    @NotNull
                                    @NotNull java.lang.reflect.Method method,
                                    @NotNull
                                    @NotNull java.lang.Class<O> outputType,
                                    @NotNull
                                    @NotNull Arguments arguments)
      • find

        public static java.util.List<java.lang.reflect.Method> find​(@NotNull
                                                                    @NotNull java.lang.Class<?> clazz,
                                                                    java.util.function.Predicate<java.lang.reflect.Method> predicate)
        Find declared methods in given class that matches with filter
        Parameters:
        clazz - Given class to find methods
        predicate - Given predicate
        Returns:
        List of matching methods
      • find

        public static java.util.stream.Stream<java.lang.reflect.Method> find​(java.util.function.Predicate<java.lang.reflect.Method> predicate,
                                                                             @NotNull
                                                                             @NotNull java.lang.Class<?> clazz)
      • validateMethod

        public static boolean validateMethod​(java.lang.reflect.Method method,
                                             java.lang.Class<?> outputType,
                                             java.lang.Class<?>... argClasses)
        Check given Method is matched with given output class and inputs class
        Parameters:
        method - Given method
        outputType - Given output type
        argClasses - Given argument classes
        Returns:
        true if matched, otherwise false
      • validateMethod

        public static boolean validateMethod​(@NotNull
                                             @NotNull java.lang.reflect.Method method,
                                             @NotNull
                                             @NotNull java.lang.Class<?> outputType,
                                             @NotNull
                                             @NotNull java.util.Collection<java.lang.Class<?>> argClasses)
        Check given Method is matched with given output class and inputs class
        Parameters:
        method - Given method
        outputType - Given output type
        argClasses - Given argument classes
        Returns:
        true if matched, otherwise false
      • validateMethod

        public static boolean validateMethod​(@NotNull
                                             @NotNull java.lang.reflect.Method method,
                                             @NotNull
                                             @NotNull java.lang.Class<?> outputType,
                                             @NotNull
                                             @NotNull Arguments arguments)
        Check given Method is matched with given output class and inputs class
        Parameters:
        method - Given method
        outputType - Given output type
        arguments - Given arguments
        Returns:
        true if matched, otherwise false