/* * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.management; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.io.StreamCorruptedException; /** *
Provides general information for an MBean descriptor object. * The feature described can be an attribute, an operation, a * parameter, or a notification. Instances of this class are * immutable. Subclasses may be mutable but this is not * recommended.
* * @since 1.5 */ public class MBeanFeatureInfo implements Serializable, DescriptorRead { /* Serial version */ static final long serialVersionUID = 3952882688968447265L; /** * The name of the feature. It is recommended that subclasses call * {@link #getName} rather than reading this field, and that they * not change it. * * @serial The name of the feature. */ protected String name; /** * The human-readable description of the feature. It is * recommended that subclasses call {@link #getDescription} rather * than reading this field, and that they not change it. * * @serial The human-readable description of the feature. */ protected String description; /** * @serial The Descriptor for this MBeanFeatureInfo. This field * can be null, which is equivalent to an empty Descriptor. */ private transient Descriptor descriptor; /** * Constructs anMBeanFeatureInfo
object. This
* constructor is equivalent to {@code MBeanFeatureInfo(name,
* description, (Descriptor) null}.
*
* @param name The name of the feature.
* @param description A human readable description of the feature.
*/
public MBeanFeatureInfo(String name, String description) {
this(name, description, null);
}
/**
* Constructs an MBeanFeatureInfo
object.
*
* @param name The name of the feature.
* @param description A human readable description of the feature.
* @param descriptor The descriptor for the feature. This may be null
* which is equivalent to an empty descriptor.
*
* @since 1.6
*/
public MBeanFeatureInfo(String name, String description,
Descriptor descriptor) {
this.name = name;
this.description = description;
this.descriptor = descriptor;
}
/**
* Returns the name of the feature.
*
* @return the name of the feature.
*/
public String getName() {
return name;
}
/**
* Returns the human-readable description of the feature.
*
* @return the human-readable description of the feature.
*/
public String getDescription() {
return description;
}
/**
* Returns the descriptor for the feature. Changing the returned value
* will have no affect on the original descriptor.
*
* @return a descriptor that is either immutable or a copy of the original.
*
* @since 1.6
*/
public Descriptor getDescriptor() {
return (Descriptor) ImmutableDescriptor.nonNullDescriptor(descriptor).clone();
}
/**
* Compare this MBeanFeatureInfo to another.
*
* @param o the object to compare to.
*
* @return true if and only if o
is an MBeanFeatureInfo such
* that its {@link #getName()}, {@link #getDescription()}, and
* {@link #getDescriptor()}
* values are equal (not necessarily identical) to those of this
* MBeanFeatureInfo.
*/
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof MBeanFeatureInfo))
return false;
MBeanFeatureInfo p = (MBeanFeatureInfo) o;
return (p.getName().equals(getName()) &&
p.getDescription().equals(getDescription()) &&
p.getDescriptor().equals(getDescriptor()));
}
public int hashCode() {
return getName().hashCode() ^ getDescription().hashCode() ^
getDescriptor().hashCode();
}
/**
* Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}.
* @serialData
* For compatibility reasons, an object of this class is serialized as follows.
*