Class Reflection

java.lang.Object
dev.getelements.elements.rt.Reflection

public class Reflection extends Object
Houses some utility logic for interacting with the Reflection API.
  • Method Details

    • isObjectInteger

      public static boolean isObjectInteger(Class<?> cls)
      Checks if the supplied Class<?> is a primitive number.
      Parameters:
      cls - the class
      Returns:
      true if the number is a primitive number
    • isPrimitiveInteger

      public static boolean isPrimitiveInteger(Class<?> cls)
      Checks if the supplied Class<?> is a primitive number.
      Parameters:
      cls - the class
      Returns:
      true if the number is a primitive number
    • isObjectFloat

      public static boolean isObjectFloat(Class<?> cls)
      Checks if the supplied Class<?> is a primitive number.
      Parameters:
      cls - the class
      Returns:
      true if the number is a primitive number
    • isPrimitiveFloat

      public static boolean isPrimitiveFloat(Class<?> cls)
      Checks if the supplied Class<?> is a primitive float.
      Parameters:
      cls - the class
      Returns:
      true if the number is a primitive number
    • format

      public static String format(Method method)
      Formats a Method for use in logging.
      Parameters:
      method - the Method
      Returns:
      the String representing the method
    • methods

      public static Stream<Method> methods(Class<?> aClass)
      Streams a Methods in a Class.
      Parameters:
      aClass - a class
      Returns:
      a Stream<Method>
    • noSuchMethod

      public static IllegalArgumentException noSuchMethod(Class<?> cls, String name)
      Returns an IllegalArgumentException with a descriptive name for the method and paramters.
      Parameters:
      cls - the type
      name - the name of the method
      Returns:
      the IllegalArgumentException
    • noSuchMethod

      public static IllegalArgumentException noSuchMethod(Class<?> cls, String name, Collection<Class<?>> args)
      Returns an IllegalArgumentException with a descriptive name for the method and paramters.
      Parameters:
      cls - the type
      name - the name of the method
      args - the argument types
      Returns:
      the IllegalArgumentException
    • noSuchMethod

      public static IllegalArgumentException noSuchMethod(Class<?> cls, String name, Class<?>[] args)
      Returns an IllegalArgumentException with a descriptive name for the method and paramters.
      Parameters:
      cls - the type
      name - the name of the method
      args - the argument types
      Returns:
      the IllegalArgumentException
    • errorHandlerIndex

      public static int errorHandlerIndex(Method method)
      Finds the Parameter index annoated with ErrorHandler in the Method
      Parameters:
      method - the Method
      Returns:
      the integer
    • indices

      public static int[] indices(Method method, Class<? extends Annotation> aClass)
      Returns the parameter indices of the Method which are anootated with the supplied annotation class.
      Parameters:
      method - the method
      aClass - the Annotation type
      Returns:
      an integer array of all indices
    • getHandlerMethod

      public static Method getHandlerMethod(Parameter parameter)
      Searches Method's parameters for a handler type.
      Parameters:
      parameter - parameter
      Returns:
    • getDefaultValue

      public static Object getDefaultValue(Parameter parameter)
      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 - the Parameter
      Returns:
      the default value
    • getDefaultValue

      public static Object getDefaultValue(Class<?> type)
      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

      public static Object getBoxedPrimitive(Class<?> type, Object boxedPrimitive)
      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

      public static int count(Method method, Class<? extends Annotation> annotationClass)