Java annotation to change null value

I want to write an annotation that can change the parameter value to some default if it is null. For example: static void myMethod(@NullToDefault String param) { System.out.println(param); } public static void main(String[] args) { myMethod("foo"); //prints "foo" myMethod(null); //prints "default" } I have separately an annotation and a method to change the null value.… Read More Java annotation to change null value

Check if Annotation is inherited

I have an annotation and three classes like this: @Inherited @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation {} @MyAnnotation public class MySuperClass {} public class MySubClassA extends MySuperClass {} @MyAnnotation public class MySubClassB extends MySuperClass {} Is there any way I can determine if a present annotation is inherited or declared directly at the class? Something like… Read More Check if Annotation is inherited