Using reflection

Now that you have learned how to declare annotations and how to attach them to classes and methods, we can return to our ProductInformation class. You may recall that we wanted to specify the type of products in this class and that each product type is represented by an @interface annotation. We have already listed it in the previous few pages, the one we will implement in our @PoweredDevice example. We will develop the code assuming that later, there will be many such annotations, product types, and consistency checkers that are annotated with @Component and with one or more of our annotations.

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.