2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / libjava / classpath / javax / management / MBeanParameterInfo.java
blob9307de46d49f0a4274580741b4c304dcbfc6ed45
1 /* MBeanParameterInfo.java -- Information about an operation's parameters.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax.management;
40 /**
41 * Describes the parameters of a constructor or operation associated
42 * with a management bean. The information in this class is immutable
43 * as standard. Of course, subclasses may change this, but this
44 * behaviour is not recommended.
46 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
47 * @since 1.5
49 public class MBeanParameterInfo
50 extends MBeanFeatureInfo
51 implements Cloneable
54 /**
55 * Compatible with JDK 1.5
57 private static final long serialVersionUID = 7432616882776782338L;
59 /**
60 * The type of the parameter, represented by the class name.
62 private String type;
64 /**
65 * Constructs a new {@link MBeanParameterInfo} using the specified
66 * name, description and type.
68 * @param name the name of the attribute.
69 * @param type the type of the attribute, in the form of its class name.
70 * @param desc a description of the attribute.
72 public MBeanParameterInfo(String name, String type, String desc)
74 super(name, desc);
75 this.type = type;
78 /**
79 * Returns a clone of this instance. The clone is created
80 * using just the method provided by {@link java.lang.Object}.
81 * Thus, the clone is just a shallow clone as returned by
82 * that method, and does not contain any deeper cloning based
83 * on the subject of this class.
85 * @return a clone of this instance.
86 * @see java.lang.Cloneable
88 public Object clone()
90 try
92 return super.clone();
94 catch (CloneNotSupportedException e)
96 /* This shouldn't happen; we implement Cloneable */
97 throw new IllegalStateException("clone() called on " +
98 "non-cloneable object.");
103 * Compares this feature with the supplied object. This returns
104 * true iff the object is an instance of {@link MBeanParameterInfo},
105 * {@link Object#equals()} returns true for a comparison of both the
106 * name and description of this parameter with that of the specified
107 * object (performed by the superclass), and the type of the two
108 * instances is equal.
110 * @param obj the object to compare.
111 * @return true if the object is a {@link MBeanParameterInfo}
112 * instance,
113 * <code>name.equals(object.getName())</code>,
114 * <code>description.equals(object.getDescription())</code>,
115 * and <code>type.equals(object.getType())</code>.
117 public boolean equals(Object obj)
119 if (!(obj instanceof MBeanParameterInfo))
120 return false;
121 if (!(super.equals(obj)))
122 return false;
123 MBeanParameterInfo o = (MBeanParameterInfo) obj;
124 return type.equals(o.getType());
128 * Returns the type of this attribute, in the form of its class name.
130 * @return the type of this attribute.
132 public String getType()
134 return type;
138 * Returns the hashcode of the parameter information as the sum of
139 * the hashcode of the superclass and the hashcode of the type.
141 * @return the hashcode of the parameter information.
143 public int hashCode()
145 return super.hashCode() + type.hashCode();
149 * <p>
150 * Returns a textual representation of this instance. This
151 * is constructed using the class name
152 * (<code>javax.management.MBeanParameterInfo</code>) along
153 * with the name, description and type of the parameter.
154 * </p>
155 * <p>
156 * As instances of this class are immutable, the return value
157 * is computed just once for each instance and reused
158 * throughout its life.
159 * </p>
161 * @return a @link{java.lang.String} instance representing
162 * the instance in textual form.
164 public String toString()
166 if (string == null)
168 super.toString();
169 string = string.substring(0, string.length() - 1)
170 + ",type=" + type
171 + "]";
173 return string;