Package 

Object EasyReflect

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static EasyReflect INSTANCE
    • Method Summary

      Modifier and Type Method Description
      final Method findMethod(Class<?> target, String name, Class<?> parameters) Get the specified method from this class.
      final Constructor<?> findConstructor(Class<?> target, Class<?> parameters) Get the specified constructor from this class.
      final Class<?> getClass(Class<?> target, String name) Get the specified inner class from this class.
      final <T extends Any> T newInstance(Class<?> target, Object arguments) Creates a new instance using the passed arguments.
      final <T extends Any> T newInstance(Constructor<?> constructor, Object arguments) Invokes this constructor, ensuring it's accessible before doing so.
      final <T extends Any> T call(Method method, Object instance, Object arguments) Invokes this method, ensuring it's accessible before doing so.
      final <T extends Any> T findAndCall(Object instance, String name, Object arguments) Call the specified method from this object by searching for methods with parameters that are compatible with the passed arguments.
      final <T extends Any> T findAndCallStatic(Class<?> target, String name, Object arguments) Call the specified static method from this class by searching for methods with parameters that are compatible with the passed arguments.
      final <T extends Any> T get(Field field, Object instance) Get the value of this field, ensuring it's accessible before doing so.
      final Unit set(Field field, Object instance, Object value) Get the value of this field, ensuring it's accessible before doing so.
      final <T extends Any> T findAndGet(Object instance, String name) Get the value of the specified field from this object.
      final Unit findAndSet(Object instance, String name, Object value) Get the value of the specified field from this object.
      final <T extends Any> T findAndGetStatic(Class<?> target, String name) Get the value of the specified static field from this object.
      final Unit findAndSetStatic(Class<?> target, String name, Object value) Get the value of the specified static field from this object.
      • Methods inherited from class java.lang.Object

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

      • findMethod

         final Method findMethod(Class<?> target, String name, Class<?> parameters)

        Get the specified method from this class. If no parameters are specified (and that didn't match a zero-parameter method), the only one with the passed name is returned. Throws if no matching methods exist or multiple matching methods exist.

      • findConstructor

         final Constructor<?> findConstructor(Class<?> target, Class<?> parameters)

        Get the specified constructor from this class. If no parameters are specified (and that didn't match a zero-parameter constructor), the only constructor is returned. Throws if no matching constructors exist or if no parameters were passed and there are multiple constructors.

      • newInstance

         final <T extends Any> T newInstance(Class<?> target, Object arguments)

        Creates a new instance using the passed arguments. Throws an exception if multiple constructors could be called with the specified argument types.

      • newInstance

         final <T extends Any> T newInstance(Constructor<?> constructor, Object arguments)

        Invokes this constructor, ensuring it's accessible before doing so.

      • call

         final <T extends Any> T call(Method method, Object instance, Object arguments)

        Invokes this method, ensuring it's accessible before doing so.

      • findAndCall

         final <T extends Any> T findAndCall(Object instance, String name, Object arguments)

        Call the specified method from this object by searching for methods with parameters that are compatible with the passed arguments. Throws if no matching methods exist or multiple matching methods exist.

      • findAndCallStatic

         final <T extends Any> T findAndCallStatic(Class<?> target, String name, Object arguments)

        Call the specified static method from this class by searching for methods with parameters that are compatible with the passed arguments. Throws if no matching methods exist or multiple matching methods exist.

      • get

         final <T extends Any> T get(Field field, Object instance)

        Get the value of this field, ensuring it's accessible before doing so.

      • set

         final Unit set(Field field, Object instance, Object value)

        Get the value of this field, ensuring it's accessible before doing so.

      • findAndGet

         final <T extends Any> T findAndGet(Object instance, String name)

        Get the value of the specified field from this object.