Interface FieldUtils


public interface FieldUtils
The utilities class for Java Reflection Field
Since:
2.7.6
  • Method Details

    • getDeclaredField

      static Field getDeclaredField(Class<?> declaredClass, String fieldName)
      Like the Class.getDeclaredField(String) method without throwing any Exception
      Parameters:
      declaredClass - the declared class
      fieldName - the name of Field
      Returns:
      if field can't be found, return null
    • findField

      static Field findField(Class<?> declaredClass, String fieldName)
      Find the Field by the name in the specified class and its inherited types
      Parameters:
      declaredClass - the declared class
      fieldName - the name of Field
      Returns:
      if can't be found, return null
    • findField

      static Field findField(Object object, String fieldName)
      Find the Field by the name in the specified class and its inherited types
      Parameters:
      object - the object whose field should be modified
      fieldName - the name of Field
      Returns:
      if can't be found, return null
    • getFieldValue

      static Object getFieldValue(Object object, String fieldName)
      Get the value of the specified Field
      Parameters:
      object - the object whose field should be modified
      fieldName - the name of Field
      Returns:
      the value of the specified Field
    • getFieldValue

      static <T> T getFieldValue(Object object, Field field)
      Get the value of the specified Field
      Parameters:
      object - the object whose field should be modified
      field - Field
      Returns:
      the value of the specified Field
    • setFieldValue

      static <T> T setFieldValue(Object object, String fieldName, T value)
      Set the value for the specified Field
      Parameters:
      object - the object whose field should be modified
      fieldName - the name of Field
      value - the value of field to be set
      Returns:
      the previous value of the specified Field
    • setFieldValue

      static <T> T setFieldValue(Object object, Field field, T value)
      Set the value for the specified Field
      Parameters:
      object - the object whose field should be modified
      field - Field
      value - the value of field to be set
      Returns:
      the previous value of the specified Field