Class ReflectionUtils


  • @Deprecated
    public class ReflectionUtils
    extends Object
    Deprecated.
    Using reflection in tests is considered as bad practice. Use it only if you don't have another option.
    Utilities to create a configured Habitat and cache them
    Author:
    David Matejcek
    • Constructor Detail

      • ReflectionUtils

        public ReflectionUtils()
        Deprecated.
    • Method Detail

      • setStaticField

        public static void setStaticField​(Class<?> clazz,
                                          String fieldName,
                                          Object value)
        Deprecated.
        Sets the static field of the class to the given value.
      • getStaticField

        public static <T> T getStaticField​(Class<?> clazz,
                                           String fieldName)
        Deprecated.
        Type Parameters:
        T - an expected assignable type of the field value.
        Returns:
        a value of the static field of the clazz
      • setField

        public static void setField​(Object instance,
                                    String fieldName,
                                    Object value)
        Deprecated.
        Sets the field of the instance to the given value.
      • getField

        public static <T> T getField​(Object instance,
                                     String fieldName)
        Deprecated.
        Type Parameters:
        T - an expected assignable type of the field value.
        Parameters:
        fieldName - a field declared in the instance's class
        Returns:
        a value of the field of the instance
      • getField

        public static <T> T getField​(Object instance,
                                     String fieldName,
                                     Class<?> ancestorOfInstance)
        Deprecated.
        Type Parameters:
        T - an expected assignable type of the field value.
        Parameters:
        fieldName - a field declared in the ancestor of the instance
        Returns:
        a value of the field of the instance