001 /*
002 * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.management;
027
028 /**
029 * Describes an argument of an operation exposed by an MBean.
030 * Instances of this class are immutable. Subclasses may be mutable
031 * but this is not recommended.
032 *
033 * @since 1.5
034 */
035 public class MBeanParameterInfo extends MBeanFeatureInfo implements
036 Cloneable {
037
038 /* Serial version */
039 static final long serialVersionUID = 7432616882776782338L;
040
041 /* All zero-length arrays are interchangeable. */
042 static final MBeanParameterInfo[] NO_PARAMS = new MBeanParameterInfo[0];
043
044 /**
045 * @serial The type or class name of the data.
046 */
047 private final String type;
048
049 /**
050 * Constructs an <CODE>MBeanParameterInfo</CODE> object.
051 *
052 * @param name The name of the data
053 * @param type The type or class name of the data
054 * @param description A human readable description of the data. Optional.
055 */
056 public MBeanParameterInfo(String name, String type,
057 String description) {
058 this (name, type, description, (Descriptor) null);
059 }
060
061 /**
062 * Constructs an <CODE>MBeanParameterInfo</CODE> object.
063 *
064 * @param name The name of the data
065 * @param type The type or class name of the data
066 * @param description A human readable description of the data. Optional.
067 * @param descriptor The descriptor for the operation. This may be null
068 * which is equivalent to an empty descriptor.
069 *
070 * @since 1.6
071 */
072 public MBeanParameterInfo(String name, String type,
073 String description, Descriptor descriptor) {
074 super (name, description, descriptor);
075
076 this .type = type;
077 }
078
079 /**
080 * <p>Returns a shallow clone of this instance.
081 * The clone is obtained by simply calling <tt>super.clone()</tt>,
082 * thus calling the default native shallow cloning mechanism
083 * implemented by <tt>Object.clone()</tt>.
084 * No deeper cloning of any internal field is made.</p>
085 *
086 * <p>Since this class is immutable, cloning is chiefly of
087 * interest to subclasses.</p>
088 */
089 public Object clone() {
090 try {
091 return super .clone();
092 } catch (CloneNotSupportedException e) {
093 // should not happen as this class is cloneable
094 return null;
095 }
096 }
097
098 /**
099 * Returns the type or class name of the data.
100 *
101 * @return the type string.
102 */
103 public String getType() {
104 return type;
105 }
106
107 public String toString() {
108 return getClass().getName() + "[" + "description="
109 + getDescription() + ", " + "name=" + getName() + ", "
110 + "type=" + getType() + ", " + "descriptor="
111 + getDescriptor() + "]";
112 }
113
114 /**
115 * Compare this MBeanParameterInfo to another.
116 *
117 * @param o the object to compare to.
118 *
119 * @return true if and only if <code>o</code> is an MBeanParameterInfo such
120 * that its {@link #getName()}, {@link #getType()},
121 * {@link #getDescriptor()}, and {@link
122 * #getDescription()} values are equal (not necessarily identical)
123 * to those of this MBeanParameterInfo.
124 */
125 public boolean equals(Object o) {
126 if (o == this )
127 return true;
128 if (!(o instanceof MBeanParameterInfo))
129 return false;
130 MBeanParameterInfo p = (MBeanParameterInfo) o;
131 return (p.getName().equals(getName())
132 && p.getType().equals(getType())
133 && p.getDescription().equals(getDescription()) && p
134 .getDescriptor().equals(getDescriptor()));
135 }
136
137 public int hashCode() {
138 return getName().hashCode() ^ getType().hashCode();
139 }
140 }
|