Inspecting annotations of the return type

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()));
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.19.174