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 int
count
(Method method, Class<? extends Annotation> annotationClass) static int
errorHandlerIndex
(Method method) static String
Formats aMethod
for use in logging.static Object
getBoxedPrimitive
(Class<?> type, Object boxedPrimitive) Gets the default value for the supplied type.static Object
getDefaultValue
(Class<?> type) Gets the default value for the supplied type.static Object
getDefaultValue
(Parameter parameter) Gets the default value for the supplied type.static Method
getHandlerMethod
(Parameter parameter) SearchesMethod
's parameters for a handler type.static int[]
indices
(Method method, Class<? extends Annotation> aClass) Returns the parameter indices of theMethod
which are anootated with the supplied annotation class.static boolean
isObjectFloat
(Class<?> cls) Checks if the suppliedClass<?>
is a primitive number.static boolean
isObjectInteger
(Class<?> cls) Checks if the suppliedClass<?>
is a primitive number.static boolean
isPrimitiveFloat
(Class<?> cls) Checks if the suppliedClass<?>
is a primitive float.static boolean
isPrimitiveInteger
(Class<?> cls) Checks if the suppliedClass<?>
is a primitive number.static IllegalArgumentException
noSuchMethod
(Class<?> cls, String name) Returns anIllegalArgumentException
with a descriptive name for the method and paramters.static IllegalArgumentException
noSuchMethod
(Class<?> cls, String name, Class<?>[] args) Returns anIllegalArgumentException
with a descriptive name for the method and paramters.static IllegalArgumentException
noSuchMethod
(Class<?> cls, String name, Collection<Class<?>> args) Returns anIllegalArgumentException
with 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 aMethod
for use in logging. -
methods
-
noSuchMethod
Returns anIllegalArgumentException
with 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 anIllegalArgumentException
with 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 anIllegalArgumentException
with 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 theMethod
which are anootated with the supplied annotation class.- Parameters:
method
- the methodaClass
- theAnnotation
type- 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
-