Path: blob/master/src/java.desktop/share/classes/java/beans/ConstructorProperties.java
41152 views
/*1* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans;2627import java.lang.annotation.*;28import static java.lang.annotation.ElementType.*;29import static java.lang.annotation.RetentionPolicy.*;3031/**32<p>An annotation on a constructor that shows how the parameters of33that constructor correspond to the constructed object's getter34methods. For example:3536<blockquote>37<pre>38public class Point {39@ConstructorProperties({"x", "y"})40public Point(int x, int y) {41this.x = x;42this.y = y;43}4445public int getX() {46return x;47}4849public int getY() {50return y;51}5253private final int x, y;54}55</pre>56</blockquote>5758The annotation shows that the first parameter of the constructor59can be retrieved with the {@code getX()} method and the second with60the {@code getY()} method. Since parameter names are not in61general available at runtime, without the annotation there would be62no way to know whether the parameters correspond to {@code getX()}63and {@code getY()} or the other way around.6465@since 1.666*/67@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME)68public @interface ConstructorProperties {69/**70<p>The getter names.</p>71@return the getter names corresponding to the parameters in the72annotated constructor.73*/74String[] value();75}767778