Package dev.getelements.elements.rt
Class Reflection
java.lang.Object
dev.getelements.elements.rt.Reflection
Houses some utility logic for interacting with the Reflection API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcount(Method method, Class<? extends Annotation> annotationClass) static interrorHandlerIndex(Method method) static StringFormats aMethodfor use in logging.static ObjectgetBoxedPrimitive(Class<?> type, Object boxedPrimitive) Gets the default value for the supplied type.static ObjectgetDefaultValue(Class<?> type) Gets the default value for the supplied type.static ObjectgetDefaultValue(Parameter parameter) Gets the default value for the supplied type.static MethodgetHandlerMethod(Parameter parameter) SearchesMethod's parameters for a handler type.static int[]indices(Method method, Class<? extends Annotation> aClass) Returns the parameter indices of theMethodwhich are anootated with the supplied annotation class.static booleanisObjectFloat(Class<?> cls) Checks if the suppliedClass<?>is a primitive number.static booleanisObjectInteger(Class<?> cls) Checks if the suppliedClass<?>is a primitive number.static booleanisPrimitiveFloat(Class<?> cls) Checks if the suppliedClass<?>is a primitive float.static booleanisPrimitiveInteger(Class<?> cls) Checks if the suppliedClass<?>is a primitive number.static IllegalArgumentExceptionnoSuchMethod(Class<?> cls, String name) Returns anIllegalArgumentExceptionwith a descriptive name for the method and paramters.static IllegalArgumentExceptionnoSuchMethod(Class<?> cls, String name, Class<?>[] args) Returns anIllegalArgumentExceptionwith a descriptive name for the method and paramters.static IllegalArgumentExceptionnoSuchMethod(Class<?> cls, String name, Collection<Class<?>> args) Returns anIllegalArgumentExceptionwith a descriptive name for the method and paramters.
-
Method Details
-
isObjectInteger
Checks if the suppliedClass<?>is a primitive number.- Parameters:
cls- the class- Returns:
- true if the number is a primitive number
-
isPrimitiveInteger
Checks if the suppliedClass<?>is a primitive number.- Parameters:
cls- the class- Returns:
- true if the number is a primitive number
-
isObjectFloat
Checks if the suppliedClass<?>is a primitive number.- Parameters:
cls- the class- Returns:
- true if the number is a primitive number
-
isPrimitiveFloat
Checks if the suppliedClass<?>is a primitive float.- Parameters:
cls- the class- Returns:
- true if the number is a primitive number
-
format
Formats aMethodfor use in logging. -
methods
-
noSuchMethod
Returns anIllegalArgumentExceptionwith a descriptive name for the method and paramters.- Parameters:
cls- the typename- the name of the method- Returns:
- the
IllegalArgumentException
-
noSuchMethod
public static IllegalArgumentException noSuchMethod(Class<?> cls, String name, Collection<Class<?>> args) Returns anIllegalArgumentExceptionwith a descriptive name for the method and paramters.- Parameters:
cls- the typename- the name of the methodargs- the argument types- Returns:
- the
IllegalArgumentException
-
noSuchMethod
Returns anIllegalArgumentExceptionwith a descriptive name for the method and paramters.- Parameters:
cls- the typename- the name of the methodargs- the argument types- Returns:
- the
IllegalArgumentException
-
errorHandlerIndex
- Parameters:
method- theMethod- Returns:
- the integer
-
indices
Returns the parameter indices of theMethodwhich are anootated with the supplied annotation class.- Parameters:
method- the methodaClass- theAnnotationtype- Returns:
- an integer array of all indices
-
getHandlerMethod
SearchesMethod's parameters for a handler type.- Parameters:
parameter- parameter- Returns:
-
getDefaultValue
Gets the default value for the supplied type. For primitive types, this is always "0" and for non-primitive types, this is null.- Parameters:
parameter- theParameter- Returns:
- the default value
-
getDefaultValue
Gets the default value for the supplied type. For primitive types, this is always "0" and for non-primitive types, this is null.- Parameters:
type- the type- Returns:
- the default value
-
getBoxedPrimitive
Gets the default value for the supplied type. For primitive types, this is always "0" and for non-primitive types, this is null.- Parameters:
type- the type- Returns:
- the default value
-
count
-