CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES 187
188 CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES Listing 10-4. @ConstructorProperties Annotation Usage import java.beans.ConstructorProperties; public class Point { private double x, y; public Point() { } @ConstructorProperties({”x”, “y”}) public Point(double x, double y) { this.x = x; this.y = y; } public double getX() { return x; } public double getY() { return y; } public void setX(double x) { this.x = x; } public void setY(double y) { this.y = y; } } By specifying the names x and y as arguments to @ConstructorProperties, you are saying that methods named getX() and getY() are available to access the property values. And, of course, that x comes first in the argument list. Tip As in Listing 10-4 with the import java.beans.ConstructorProperties; line, don t forget to import the classes for the annotations. Without the import line, the compiler will look in the default package for the annotation class (@ConstructorProperties here). The compiler has no internal mapping of annotations to classes in other packages.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services