Path: blob/master/src/java.management/share/classes/javax/management/MBeanParameterInfo.java
41154 views
/*1* Copyright (c) 1999, 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 javax.management;2627import java.util.Objects;282930/**31* Describes an argument of an operation exposed by an MBean.32* Instances of this class are immutable. Subclasses may be mutable33* but this is not recommended.34*35* @since 1.536*/37public class MBeanParameterInfo extends MBeanFeatureInfo implements Cloneable {3839/* Serial version */40static final long serialVersionUID = 7432616882776782338L;4142/* All zero-length arrays are interchangeable. */43static final MBeanParameterInfo[] NO_PARAMS = new MBeanParameterInfo[0];4445/**46* @serial The type or class name of the data.47*/48private final String type;495051/**52* Constructs an {@code MBeanParameterInfo} object.53*54* @param name The name of the data55* @param type The type or class name of the data56* @param description A human readable description of the data. Optional.57*/58public MBeanParameterInfo(String name,59String type,60String description) {61this(name, type, description, (Descriptor) null);62}6364/**65* Constructs an {@code MBeanParameterInfo} object.66*67* @param name The name of the data68* @param type The type or class name of the data69* @param description A human readable description of the data. Optional.70* @param descriptor The descriptor for the operation. This may be null71* which is equivalent to an empty descriptor.72*73* @since 1.674*/75public MBeanParameterInfo(String name,76String type,77String description,78Descriptor descriptor) {79super(name, description, descriptor);8081this.type = type;82}838485/**86* <p>Returns a shallow clone of this instance.87* The clone is obtained by simply calling {@code super.clone()},88* thus calling the default native shallow cloning mechanism89* implemented by {@code Object.clone()}.90* No deeper cloning of any internal field is made.</p>91*92* <p>Since this class is immutable, cloning is chiefly of93* interest to subclasses.</p>94*/95public Object clone () {96try {97return super.clone() ;98} catch (CloneNotSupportedException e) {99// should not happen as this class is cloneable100return null;101}102}103104/**105* Returns the type or class name of the data.106*107* @return the type string.108*/109public String getType() {110return type;111}112113public String toString() {114return115getClass().getName() + "[" +116"description=" + getDescription() + ", " +117"name=" + getName() + ", " +118"type=" + getType() + ", " +119"descriptor=" + getDescriptor() +120"]";121}122123/**124* Compare this MBeanParameterInfo to another.125*126* @param o the object to compare to.127*128* @return true if and only if {@code o} is an MBeanParameterInfo such129* that its {@link #getName()}, {@link #getType()},130* {@link #getDescriptor()}, and {@link131* #getDescription()} values are equal (not necessarily identical)132* to those of this MBeanParameterInfo.133*/134public boolean equals(Object o) {135if (o == this)136return true;137if (!(o instanceof MBeanParameterInfo))138return false;139MBeanParameterInfo p = (MBeanParameterInfo) o;140return (Objects.equals(p.getName(), getName()) &&141Objects.equals(p.getType(), getType()) &&142Objects.equals(p.getDescription(), getDescription()) &&143Objects.equals(p.getDescriptor(), getDescriptor()));144}145146public int hashCode() {147return Objects.hash(getName(), getType());148}149}150151152