September 2019
Intermediate to advanced
816 pages
18h 47m
English
For inspecting the annotations of a method return, we need to call the getAnnotatedReturnType() method:

This method returns the annotated return type of the given method:
Class<Melon> clazz = Melon.class;Method methodSeeds = clazz.getDeclaredMethod("seeds");AnnotatedType returnType = methodSeeds.getAnnotatedReturnType();// java.util.List<modern.challenge.Seed>System.out.println("Return type: " + returnType.getType().getTypeName());// [@modern.challenge.Shape(value="oval")]System.out.println("Annotations of the return type: " + Arrays.toString(returnType.getAnnotations()));
Read now
Unlock full access