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.io.IOException;
29 import java.io.ObjectInputStream;
30 import java.io.ObjectOutputStream;
31 import java.io.Serializable;
32 import java.io.StreamCorruptedException;
33
34 /**
35 * <p>Provides general information for an MBean descriptor object.
36 * The feature described can be an attribute, an operation, a
37 * parameter, or a notification. Instances of this class are
38 * immutable. Subclasses may be mutable but this is not
39 * recommended.</p>
40 *
41 * @since 1.5
42 */
43 public class MBeanFeatureInfo implements Serializable, DescriptorRead {
44
45
46 /* Serial version */
47 static final long serialVersionUID = 3952882688968447265L;
48
49 /**
50 * The name of the feature. It is recommended that subclasses call
51 * {@link #getName} rather than reading this field, and that they
52 * not change it.
130 return (Descriptor) ImmutableDescriptor.nonNullDescriptor(descriptor).clone();
131 }
132
133 /**
134 * Compare this MBeanFeatureInfo to another.
135 *
136 * @param o the object to compare to.
137 *
138 * @return true if and only if <code>o</code> is an MBeanFeatureInfo such
139 * that its {@link #getName()}, {@link #getDescription()}, and
140 * {@link #getDescriptor()}
141 * values are equal (not necessarily identical) to those of this
142 * MBeanFeatureInfo.
143 */
144 public boolean equals(Object o) {
145 if (o == this)
146 return true;
147 if (!(o instanceof MBeanFeatureInfo))
148 return false;
149 MBeanFeatureInfo p = (MBeanFeatureInfo) o;
150 return (p.getName().equals(getName()) &&
151 p.getDescription().equals(getDescription()) &&
152 p.getDescriptor().equals(getDescriptor()));
153 }
154
155 public int hashCode() {
156 return getName().hashCode() ^ getDescription().hashCode() ^
157 getDescriptor().hashCode();
158 }
159
160 /**
161 * Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}.
162 * @serialData
163 * For compatibility reasons, an object of this class is serialized as follows.
164 * <ul>
165 * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()}
166 * is called first to serialize the object except the field {@code descriptor}
167 * which is declared as transient. The field {@code descriptor} is serialized
168 * as follows:
169 * <ul>
170 * <li>If {@code descriptor} is an instance of the class
171 * {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write
172 * write(int val)} is called to write a byte with the value {@code 1},
|
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.io.IOException;
29 import java.io.ObjectInputStream;
30 import java.io.ObjectOutputStream;
31 import java.io.Serializable;
32 import java.io.StreamCorruptedException;
33 import java.util.Objects;
34
35 /**
36 * <p>Provides general information for an MBean descriptor object.
37 * The feature described can be an attribute, an operation, a
38 * parameter, or a notification. Instances of this class are
39 * immutable. Subclasses may be mutable but this is not
40 * recommended.</p>
41 *
42 * @since 1.5
43 */
44 public class MBeanFeatureInfo implements Serializable, DescriptorRead {
45
46
47 /* Serial version */
48 static final long serialVersionUID = 3952882688968447265L;
49
50 /**
51 * The name of the feature. It is recommended that subclasses call
52 * {@link #getName} rather than reading this field, and that they
53 * not change it.
131 return (Descriptor) ImmutableDescriptor.nonNullDescriptor(descriptor).clone();
132 }
133
134 /**
135 * Compare this MBeanFeatureInfo to another.
136 *
137 * @param o the object to compare to.
138 *
139 * @return true if and only if <code>o</code> is an MBeanFeatureInfo such
140 * that its {@link #getName()}, {@link #getDescription()}, and
141 * {@link #getDescriptor()}
142 * values are equal (not necessarily identical) to those of this
143 * MBeanFeatureInfo.
144 */
145 public boolean equals(Object o) {
146 if (o == this)
147 return true;
148 if (!(o instanceof MBeanFeatureInfo))
149 return false;
150 MBeanFeatureInfo p = (MBeanFeatureInfo) o;
151 return (Objects.equals(p.getName(), getName()) &&
152 Objects.equals(p.getDescription(), getDescription()) &&
153 Objects.equals(p.getDescriptor(), getDescriptor()));
154 }
155
156 public int hashCode() {
157 return getName().hashCode() ^ getDescription().hashCode() ^
158 getDescriptor().hashCode();
159 }
160
161 /**
162 * Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}.
163 * @serialData
164 * For compatibility reasons, an object of this class is serialized as follows.
165 * <ul>
166 * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()}
167 * is called first to serialize the object except the field {@code descriptor}
168 * which is declared as transient. The field {@code descriptor} is serialized
169 * as follows:
170 * <ul>
171 * <li>If {@code descriptor} is an instance of the class
172 * {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write
173 * write(int val)} is called to write a byte with the value {@code 1},
|