src/java.management/share/classes/javax/management/ConstructorParameters.java
changeset 47216 71c04702a3d5
parent 39759 427916042881
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package javax.management;
       
    27 
       
    28 import java.lang.annotation.*;
       
    29 import static java.lang.annotation.ElementType.*;
       
    30 import static java.lang.annotation.RetentionPolicy.*;
       
    31 
       
    32 /**
       
    33  * <p>
       
    34  * An annotation on a constructor that shows how the parameters of
       
    35  * that constructor correspond to the constructed object's getter
       
    36  * methods.  For example:
       
    37  * </p>
       
    38  * <blockquote>
       
    39  *     <pre>
       
    40  *         public class MemoryUsage {
       
    41  *             // standard JavaBean conventions with getters
       
    42  *             <b>@ConstructorParameters({"init", "used", "committed", "max"})</b>
       
    43  *             public MemoryUsage(long init, long used,
       
    44  *                                long committed, long max) {...}
       
    45  *             public long getInit() {...}
       
    46  *             public long getUsed() {...}
       
    47  *             public long getCommitted() {...}
       
    48  *             public long getMax() {...}
       
    49  *         }
       
    50  *     </pre>
       
    51  * </blockquote>
       
    52  * <p>
       
    53  * The annotation shows that the first parameter of the constructor
       
    54  * can be retrieved with the {@code getInit()} method, the second one with
       
    55  * the {@code getUsed()} method, and so on. Since parameter names are not in
       
    56  * general available at runtime, without the annotation there would be
       
    57  * no way of knowing which parameter corresponds to which property.
       
    58  * </p>
       
    59  * <p>
       
    60  * If a constructor is annotated by the both {@code @java.beans.ConstructorProperties}
       
    61  * and {@code @javax.management.ConstructorParameters} annotations
       
    62  * the JMX introspection will give an absolute precedence to the latter one.
       
    63  * </p>
       
    64  *
       
    65  * @since 9
       
    66  */
       
    67 @Documented @Target(CONSTRUCTOR) @Retention(RUNTIME)
       
    68 public @interface ConstructorParameters {
       
    69     /**
       
    70      * <p>The getter names.</p>
       
    71      *
       
    72      * @return the getter names corresponding to the parameters in the
       
    73      * annotated constructor.
       
    74     */
       
    75     String[] value();
       
    76 }