Package com.comphenix.protocol.reflect
Class ExactReflection
java.lang.Object
com.comphenix.protocol.reflect.ExactReflection
-
Method Summary
Modifier and TypeMethodDescriptionConstructor<?> findConstructor(Class<?>... parameters) Finds the first constructor in the class hierarchy with the given parameters.Finds a field in the class hierarchy by the given name.findMethod(String methodName, Class<?>... parameters) Finds the first method in the class hierarchy with the given name and parameters.Retrieve anExactReflectionobject where scope restrictions are ignored.static ExactReflectionRetrieves an exact reflection instance from a given class.static ExactReflectionfromObject(Object reference, boolean forceAccess) Retrieves an exact reflection instance from an object.Constructor<?> getConstructor(Class<?>... parameters) Retrieves the first constructor in the class hierarchy with the given parameters.Retrieve a field in the class hierarchy by the given name.Retrieve the first method in the class hierarchy with the given name and parameters.Class<?> Retrieve the source class we are searching.booleanDetermine if we are overriding scope restrictions and will also find private, protected or package members.
-
Method Details
-
fromClass
Retrieves an exact reflection instance from a given class.- Parameters:
source- - the class we'll use.forceAccess- - whether to also search for members which are out of the allowed scope.- Returns:
- A fuzzy reflection instance.
-
fromObject
Retrieves an exact reflection instance from an object.- Parameters:
reference- - the object we'll use.forceAccess- - whether to also search for members which are out of the allowed scope.- Returns:
- A fuzzy reflection instance that uses the class of the given object.
-
getMethod
Retrieve the first method in the class hierarchy with the given name and parameters.If
isForceAccess()is TRUE, we will also search for methods which are out of the caller scope.- Parameters:
methodName- - the name of the method to find, NULL to only search by using the given parameters.parameters- - the parameters of the method to find.- Returns:
- the first matching method.
- Throws:
IllegalArgumentException- if there is no method with the given name and parameter types.
-
findMethod
Finds the first method in the class hierarchy with the given name and parameters.If
isForceAccess()is TRUE, we will also search for methods which are out of the caller scope.- Parameters:
methodName- - the name of the method to find, NULL to only search by using the given parameters.parameters- - the parameters of the method to find.- Returns:
- the first matching method, NULL if no method matches.
-
getField
Retrieve a field in the class hierarchy by the given name.If
isForceAccess()is TRUE, we will also search for fields which are out of the caller scope.- Parameters:
fieldName- - the name of the field to find.- Returns:
- the first matching field.
- Throws:
IllegalArgumentException- if no field with the given name was found.
-
findField
Finds a field in the class hierarchy by the given name.If
isForceAccess()is TRUE, we will also search for fields which are out of the caller scope.- Parameters:
fieldName- - the name of the field to find.- Returns:
- the first matching field, null if no field matches.
-
getConstructor
Retrieves the first constructor in the class hierarchy with the given parameters.If
isForceAccess()is TRUE, we will also search for constructors which are out of the caller scope.- Parameters:
parameters- - the parameters of the constructor to find.- Returns:
- the first matching constructor.
- Throws:
IllegalArgumentException- if no constructor with the given parameters was found.
-
findConstructor
Finds the first constructor in the class hierarchy with the given parameters.If
isForceAccess()is TRUE, we will also search for constructors which are out of the caller scope.- Parameters:
parameters- - the parameters of the constructor to find.- Returns:
- the first matching constructor, NULL if no constructor matches.
-
forceAccess
Retrieve anExactReflectionobject 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
Retrieve the source class we are searching.- Returns:
- The source.
-