src/java.management/share/classes/javax/management/MBeanParameterInfo.java
author darcy
Wed, 23 Oct 2019 13:01:40 -0700
changeset 58766 54ffb15c4839
parent 47216 71c04702a3d5
permissions -rw-r--r--
8232442: Suppress warnings on non-serializable non-transient instance fields in java.management.* Reviewed-by: rriggs, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20174
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
19852
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents: 5506
diff changeset
    28
import java.util.Objects;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
20174
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 19852
diff changeset
    30
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Describes an argument of an operation exposed by an MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Instances of this class are immutable.  Subclasses may be mutable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * but this is not recommended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class MBeanParameterInfo extends MBeanFeatureInfo implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /* Serial version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    static final long serialVersionUID = 7432616882776782338L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /* All zero-length arrays are interchangeable. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    static final MBeanParameterInfo[] NO_PARAMS = new MBeanParameterInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * @serial The type or class name of the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private final String type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    53
     * Constructs an {@code MBeanParameterInfo} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @param name The name of the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @param type The type or class name of the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @param description A human readable description of the data. Optional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public MBeanParameterInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                              String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                              String description) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        this(name, type, description, (Descriptor) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    66
     * Constructs an {@code MBeanParameterInfo} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param name The name of the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param type The type or class name of the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param description A human readable description of the data. Optional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param descriptor The descriptor for the operation.  This may be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * which is equivalent to an empty descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public MBeanParameterInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                              String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                              String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                              Descriptor descriptor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        super(name, description, descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * <p>Returns a shallow clone of this instance.
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    88
     * The clone is obtained by simply calling {@code super.clone()},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * thus calling the default native shallow cloning mechanism
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    90
     * implemented by {@code Object.clone()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * No deeper cloning of any internal field is made.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * <p>Since this class is immutable, cloning is chiefly of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * interest to subclasses.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     public Object clone () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
         try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
             return super.clone() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
         } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
             // should not happen as this class is cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
             return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns the type or class name of the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @return the type string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public String getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            getClass().getName() + "[" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            "description=" + getDescription() + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            "name=" + getName() + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            "type=" + getType() + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            "descriptor=" + getDescriptor() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Compare this MBeanParameterInfo to another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param o the object to compare to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   129
     * @return true if and only if {@code o} is an MBeanParameterInfo such
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * that its {@link #getName()}, {@link #getType()},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * {@link #getDescriptor()}, and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * #getDescription()} values are equal (not necessarily identical)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * to those of this MBeanParameterInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (o == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        if (!(o instanceof MBeanParameterInfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        MBeanParameterInfo p = (MBeanParameterInfo) o;
20174
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 19852
diff changeset
   141
        return (Objects.equals(p.getName(), getName()) &&
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 19852
diff changeset
   142
                Objects.equals(p.getType(), getType()) &&
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 19852
diff changeset
   143
                Objects.equals(p.getDescription(), getDescription()) &&
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 19852
diff changeset
   144
                Objects.equals(p.getDescriptor(), getDescriptor()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public int hashCode() {
19852
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents: 5506
diff changeset
   148
        return Objects.hash(getName(), getType());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
}