Class ReflectionUtil


  • public class ReflectionUtil
    extends java.lang.Object
    Provides utility methods that can be used access and mutate objects using reflection.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertCallerAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.String message)
      Ensures if the caller of the method calling this method is annotated with the specified annotation.
      static boolean setField​(java.lang.Object source, java.lang.String fieldName, java.lang.Object value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setField

        public static boolean setField​(@NonNull
                                       java.lang.Object source,
                                       @NonNull
                                       java.lang.String fieldName,
                                       @Nullable
                                       java.lang.Object value)
      • assertCallerAnnotation

        public static void assertCallerAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
                                                  java.lang.String message)
        Ensures if the caller of the method calling this method is annotated with the specified annotation.
        Parameters:
        annotationClass - the expected annotation class
        message - the message that will included the exception if the check fails.
        Throws:
        java.lang.UnsupportedOperationException - if the caller if the caller is not annotated as expected.