Class Reflections

java.lang.Object
com.github.mjeanroy.dbunit.commons.reflection.Reflections

public final class Reflections extends Object
Internal reflection utilities used by the dbUnit extension.

Warning: This class is part of the internal implementation and is not considered public API. It may change or be removed at any time without notice, and should not be used directly in external code.

  • Method Details

    • extractMembers

      public static Map<String,Field> extractMembers(Object instance)
      Extracts all declared field values from the given object instance, including fields inherited from superclasses (up to but excluding Object).

      The returned map preserves the encounter order of the fields as they are discovered in the class hierarchy (starting from the concrete class and moving up to its superclasses). Field names are used as keys and their corresponding values are the map values.

      If a field with the same name exists in both a subclass and a superclass, the value from the subclass takes precedence. The returned map is unmodifiable; attempts to modify it will result in UnsupportedOperationException.

      Internal API: This method is intended for internal use only and is not part of the public API. Its behavior and signature may change without notice.

      Parameters:
      instance - The object to introspect; may be null.
      Returns:
      An unmodifiable map containing field names as keys and their values as retrieved from the given instance. If instance is null, an empty map is returned.
      Throws:
      FieldAccessException - if a field value cannot be accessed via reflection.
    • getFieldValueSafely

      public static Object getFieldValueSafely(Object instance, Field field)
      Get value of given instance field, temporarily switching to an accessible field to get the value.
      Parameters:
      instance - The instance.
      field - The field.
      Returns:
      The field value.