Class ReflectionUtils

java.lang.Object
dev.voidframework.core.utils.ReflectionUtils

public final class ReflectionUtils extends Object
Reflection-based utility methods.
  • Method Details

    • getAnnotatedField

      public static Field getAnnotatedField(Object classInstance, Class<? extends Annotation> annotationClassType)
      Retrieves a specific annotated field.
      Parameters:
      classInstance - The instance of the class in which the field is located
      annotationClassType - The annotation
      Returns:
      The field, otherwise, null
    • getAnnotatedField

      public static Field getAnnotatedField(Class<?> classType, Class<? extends Annotation> annotationClassType)
      Retrieves a specific annotated field.
      Parameters:
      classType - The class type in which the field is located
      annotationClassType - The annotation
      Returns:
      The field, otherwise, null
    • getFieldValue

      public static <T> T getFieldValue(Object classInstance, String fieldName, Class<T> valueTypeClass)
      Retrieves the value of a specific field.
      Type Parameters:
      T - The value type
      Parameters:
      classInstance - The instance of the class in which the field is located
      fieldName - The field name
      valueTypeClass - The value class type
      Returns:
      The field value, otherwise, null
    • getFieldValue

      public static <T> T getFieldValue(Object classInstance, String fieldName, ReflectionUtils.WrappedClass<T> wrappedClass)
      Retrieves the value of a specific field.
      Type Parameters:
      T - The value type
      Parameters:
      classInstance - The instance of the class in which the field is located
      fieldName - The field name
      wrappedClass - The value class type (wrapped)
      Returns:
      The field value, otherwise, null
    • setFieldValue

      public static void setFieldValue(Object classInstance, String fieldName, Object value)
      Sets the value of a specific field.
      Parameters:
      classInstance - The instance of the class in which the field is located
      fieldName - The field name
      value - The value
    • resolveMethod

      public static Method resolveMethod(String methodName, Class<?> classType)
      Resolves a methode from it name.
      Parameters:
      methodName - The method name
      classType - The class where are located this method
      Returns:
      The method
    • callMethod

      public static <T> T callMethod(Object classInstance, String methodeName, Class<T> returnTypeClass, Class<?>[] argumentTypeArray, Object... argumentArray)
      Calls a method.
      Type Parameters:
      T - Type of the return value
      Parameters:
      classInstance - The instance of the class in which the method is located
      methodeName - The method name
      returnTypeClass - The returned value type
      argumentTypeArray - The method argument types
      argumentArray - The method arguments
      Returns:
      The method call result
    • callMethod

      public static void callMethod(Object classInstance, String methodeName, Class<?>[] argumentTypeArray, Object... argumentArray)
      Calls a method.
      Parameters:
      classInstance - The instance of the class in which the method is located
      methodeName - The method name
      argumentTypeArray - The method argument types
      argumentArray - The method arguments