public class FuzzyReflection
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MINECRAFT_OBJECT
Matches a Minecraft object.
|
Constructor and Description |
---|
FuzzyReflection(java.lang.Class<?> source,
boolean forceAccess) |
Modifier and Type | Method and Description |
---|---|
static FuzzyReflection |
fromClass(java.lang.Class<?> source)
Retrieves a fuzzy reflection instance from a given class.
|
static FuzzyReflection |
fromClass(java.lang.Class<?> source,
boolean forceAccess)
Retrieves a fuzzy reflection instance from a given class.
|
static FuzzyReflection |
fromObject(java.lang.Object reference)
Retrieves a fuzzy reflection instance from an object.
|
static FuzzyReflection |
fromObject(java.lang.Object reference,
boolean forceAccess)
Retrieves a fuzzy reflection instance from an object.
|
java.lang.reflect.Field |
getFieldByName(java.lang.String nameRegex)
Retrieves a field by name.
|
java.lang.reflect.Field |
getFieldByType(java.lang.String typeRegex)
Retrieves a field by type.
|
java.lang.reflect.Field |
getFieldByType(java.lang.String name,
java.lang.Class<?> type)
Retrieves the first field with a type equal to or more specific to the given type.
|
java.lang.reflect.Field |
getFieldByType(java.lang.String typeRegex,
java.util.Set<java.lang.Class> ignored)
Retrieves a field by type.
|
java.util.List<java.lang.reflect.Field> |
getFieldListByType(java.lang.Class<?> type)
Retrieves every field with a type equal to or more specific to the given type.
|
java.util.Set<java.lang.reflect.Field> |
getFields()
Retrieves all private and public fields in declared order (after JDK 1.5).
|
java.lang.reflect.Method |
getMethodByName(java.lang.String nameRegex)
Retrieves a method by looking at its name.
|
java.lang.reflect.Method |
getMethodByParameters(java.lang.String name,
java.lang.Class<?>... args)
Retrieves a method by looking at the parameter types only.
|
java.lang.reflect.Method |
getMethodByParameters(java.lang.String name,
java.lang.Class<?> returnType,
java.lang.Class<?>[] args)
Retrieves a method by looking at the parameter types and return type only.
|
java.lang.reflect.Method |
getMethodByParameters(java.lang.String name,
java.lang.String returnTypeRegex,
java.lang.String[] argsRegex)
Retrieves a method by looking at the parameter types and return type only.
|
java.util.List<java.lang.reflect.Method> |
getMethodListByParameters(java.lang.Class<?> returnType,
java.lang.Class<?>[] args)
Retrieves every method that has the given parameter types and return type.
|
java.util.Set<java.lang.reflect.Method> |
getMethods()
Retrieves all private and public methods in declared order (after JDK 1.5).
|
java.lang.Class<?> |
getSource()
Retrieves the underlying class.
|
boolean |
isForceAccess()
Retrieves whether or not not to override any scope restrictions.
|
void |
setForceAccess(boolean forceAccess)
Sets whether or not not to override any scope restrictions.
|
public static java.lang.String MINECRAFT_OBJECT
public FuzzyReflection(java.lang.Class<?> source, boolean forceAccess)
public static FuzzyReflection fromClass(java.lang.Class<?> source)
source
- - the class we'll use.public static FuzzyReflection fromClass(java.lang.Class<?> source, boolean forceAccess)
source
- - the class we'll use.forceAccess
- - whether or not to override scope restrictions.public static FuzzyReflection fromObject(java.lang.Object reference)
reference
- - the object we'll use.public static FuzzyReflection fromObject(java.lang.Object reference, boolean forceAccess)
reference
- - the object we'll use.forceAccess
- - whether or not to override scope restrictions.public java.lang.Class<?> getSource()
public java.lang.reflect.Method getMethodByName(java.lang.String nameRegex)
nameRegex
- - regular expression that will match method names.java.lang.RuntimeException
- If the method cannot be found.public java.lang.reflect.Method getMethodByParameters(java.lang.String name, java.lang.Class<?>... args)
name
- - potential name of the method. Only used by the error mechanism.args
- - parameter types of the method to find.public java.lang.reflect.Method getMethodByParameters(java.lang.String name, java.lang.Class<?> returnType, java.lang.Class<?>[] args)
name
- - potential name of the method. Only used by the error mechanism.returnType
- - return type of the method to find.args
- - parameter types of the method to find.public java.lang.reflect.Method getMethodByParameters(java.lang.String name, java.lang.String returnTypeRegex, java.lang.String[] argsRegex)
name
- - potential name of the method. Only used by the error mechanism.returnTypeRegex
- - regular expression matching the return type of the method to find.argsRegex
- - regular expressions of the matching parameter types.public java.util.List<java.lang.reflect.Method> getMethodListByParameters(java.lang.Class<?> returnType, java.lang.Class<?>[] args)
returnType
- - return type of the method to find.args
- - parameter types of the method to find.public java.lang.reflect.Field getFieldByName(java.lang.String nameRegex)
nameRegex
- - regular expression that will match a field name.public java.lang.reflect.Field getFieldByType(java.lang.String name, java.lang.Class<?> type)
name
- - name the field probably is given. This will only be used in the error message.type
- - type of the field to find.public java.util.List<java.lang.reflect.Field> getFieldListByType(java.lang.Class<?> type)
type
- - type of the fields to find.public java.lang.reflect.Field getFieldByType(java.lang.String typeRegex)
Note that the type is matched using the full canonical representation, i.e.:
typeRegex
- - regular expression that will match the field type.public java.lang.reflect.Field getFieldByType(java.lang.String typeRegex, java.util.Set<java.lang.Class> ignored)
Note that the type is matched using the full canonical representation, i.e.:
typeRegex
- - regular expression that will match the field type.ignored
- - types to ignore.public java.util.Set<java.lang.reflect.Field> getFields()
public java.util.Set<java.lang.reflect.Method> getMethods()
public boolean isForceAccess()
public void setForceAccess(boolean forceAccess)
forceAccess
- - TRUE if we override scope, FALSE otherwise.