Path: blob/master/src/java.management/share/classes/javax/management/ConstructorParameters.java
41155 views
/*1* Copyright (c) 2006, 2015, 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 javax.management;2627import java.lang.annotation.*;28import static java.lang.annotation.ElementType.*;29import static java.lang.annotation.RetentionPolicy.*;3031/**32* <p>33* An annotation on a constructor that shows how the parameters of34* that constructor correspond to the constructed object's getter35* methods. For example:36* </p>37* <blockquote>38* <pre>39* public class MemoryUsage {40* // standard JavaBean conventions with getters41* <b>@ConstructorParameters({"init", "used", "committed", "max"})</b>42* public MemoryUsage(long init, long used,43* long committed, long max) {...}44* public long getInit() {...}45* public long getUsed() {...}46* public long getCommitted() {...}47* public long getMax() {...}48* }49* </pre>50* </blockquote>51* <p>52* The annotation shows that the first parameter of the constructor53* can be retrieved with the {@code getInit()} method, the second one with54* the {@code getUsed()} method, and so on. Since parameter names are not in55* general available at runtime, without the annotation there would be56* no way of knowing which parameter corresponds to which property.57* </p>58* <p>59* If a constructor is annotated by the both {@code @java.beans.ConstructorProperties}60* and {@code @javax.management.ConstructorParameters} annotations61* the JMX introspection will give an absolute precedence to the latter one.62* </p>63*64* @since 965*/66@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME)67public @interface ConstructorParameters {68/**69* <p>The getter names.</p>70*71* @return the getter names corresponding to the parameters in the72* annotated constructor.73*/74String[] value();75}767778