1 /* 2 * @(#)ConstructorProperties.java 1.1 06/02/27 3 * 4 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package java.beans; 9 10 import java.lang.annotation.*; 11 import static java.lang.annotation.ElementType.*; 12 import static java.lang.annotation.RetentionPolicy.*; 13 14 /** 15 <p>An annotation on a constructor that shows how the parameters of 16 that constructor correspond to the constructed object's getter 17 methods. For example: 18 19 <blockquote> 20 <pre> 21 public class Point { 22 @ConstructorProperties({"x", "y"}) 23 public Point(int x, int y) { 24 this.x = x; 25 this.y = y; 26 } 27 28 public int getX() { 29 return x; 30 } 31 32 public int getY() { 33 return y; 34 } 35 36 private final int x, y; 37 } 38 </pre> 39 </blockquote> 40 41 The annotation shows that the first parameter of the constructor 42 can be retrieved with the {@code getX()} method and the second with 43 the {@code getY()} method. Since parameter names are not in 44 general available at runtime, without the annotation there would be 45 no way to know whether the parameters correspond to {@code getX()} 46 and {@code getY()} or the other way around.</p> 47 48 @since 1.6 49 */ 50 @Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) 51 public @interface ConstructorProperties { 52 /** 53 <p>The getter names.</p> 54 @return the getter names corresponding to the parameters in the 55 annotated constructor. 56 */ 57 String[] value(); 58 } 59