Class ExactReflection

java.lang.Object
com.comphenix.protocol.reflect.ExactReflection

public class ExactReflection extends Object
  • Method Details

    • fromClass

      public static ExactReflection fromClass(Class<?> source)
      Retrieves an exact reflection instance from a given class.
      Parameters:
      source - - the class we'll use.
      Returns:
      A fuzzy reflection instance.
    • fromClass

      public static ExactReflection fromClass(Class<?> source, boolean forceAccess)
      Retrieves an exact reflection instance from a given class.
      Parameters:
      source - - the class we'll use.
      forceAccess - - whether or not to override scope restrictions.
      Returns:
      A fuzzy reflection instance.
    • fromObject

      public static ExactReflection fromObject(Object reference)
      Retrieves an exact reflection instance from an object.
      Parameters:
      reference - - the object we'll use.
      Returns:
      A fuzzy reflection instance that uses the class of the given object.
    • fromObject

      public static ExactReflection fromObject(Object reference, boolean forceAccess)
      Retrieves an exact reflection instance from an object.
      Parameters:
      reference - - the object we'll use.
      forceAccess - - whether or not to override scope restrictions.
      Returns:
      A fuzzy reflection instance that uses the class of the given object.
    • getMethod

      public Method getMethod(String methodName, Class<?>... parameters)
      Retrieve the first method in the class hierachy with the given name and parameters.

      If isForceAccess() is TRUE, we will also search for protected and private methods.

      Parameters:
      methodName - - the method name to find, or NULL to look for everything.
      parameters - - the parameters.
      Returns:
      The first matched method.
      Throws:
      IllegalArgumentException - If we cannot find a method by this name.
    • getField

      public Field getField(String fieldName)
      Retrieve a field in the class hierachy by the given name.

      If isForceAccess() is TRUE, we will also search for protected and private fields.

      Parameters:
      fieldName - - the field name. Cannot be NULL.
      Returns:
      The first matched field.
    • forceAccess

      public ExactReflection forceAccess()
      Retrieve an ExactReflection object where scope restrictions are ignored.
      Returns:
      A copy of the current object.
    • isForceAccess

      public boolean isForceAccess()
      Determine if we are overriding scope restrictions and will also find private, protected or package members.
      Returns:
      TRUE if we are, FALSE otherwise.
    • getSource

      public Class<?> getSource()
      Retrieve the source class we are searching.
      Returns:
      The source.