001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management;
023:
024: /**
025: * Describes an argument of an operation exposed by an MBean
026: *
027: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
028: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
029: *
030: * @version $Revision: 57200 $
031: *
032: * <p><b>Revisions:</b>
033: * <p><b>20020711 Adrian Brock:</b>
034: * <ul>
035: * <li> Serialization </li>
036: * </ul>
037: */
038: public class MBeanParameterInfo extends MBeanFeatureInfo implements
039: java.io.Serializable, Cloneable {
040: // Constants -----------------------------------------------------
041:
042: private static final long serialVersionUID = 7432616882776782338L;
043:
044: // Attributes ----------------------------------------------------
045: private String type = null;
046:
047: /**
048: * The cached string
049: */
050: private transient String cacheString;
051:
052: /**
053: * The cached hashCode
054: */
055: private transient int cacheHashCode;
056:
057: // Constructors --------------------------------------------------
058: public MBeanParameterInfo(java.lang.String name,
059: java.lang.String type, java.lang.String description)
060: throws IllegalArgumentException {
061: super (name, description);
062: /* Removed as of the 1.2 management release
063: if (MetaDataUtil.isValidJavaType(type) == false)
064: throw new IllegalArgumentException("type is not a valid java type (or is a reserved word): " + type);
065: */
066:
067: this .type = type;
068: }
069:
070: // Public --------------------------------------------------------
071: public java.lang.String getType() {
072: return type;
073: }
074:
075: public boolean equals(Object object) {
076: if (this == object)
077: return true;
078: if (object == null
079: || (object instanceof MBeanParameterInfo) == false)
080: return false;
081:
082: MBeanParameterInfo other = (MBeanParameterInfo) object;
083:
084: if (super .equals(other) == false)
085: return false;
086: if (this .getType().equals(other.getType()) == false)
087: return false;
088:
089: return true;
090: }
091:
092: public int hashCode() {
093: if (cacheHashCode == 0) {
094: cacheHashCode = super .hashCode();
095: cacheHashCode += getType().hashCode();
096: }
097: return cacheHashCode;
098: }
099:
100: /**
101: * @return a human readable string
102: */
103: public String toString() {
104: if (cacheString == null) {
105: StringBuffer buffer = new StringBuffer(100);
106: buffer.append(getClass().getName()).append(":");
107: buffer.append(" name=").append(getName());
108: buffer.append(" description=").append(getDescription());
109: buffer.append(" type=").append(getType());
110: cacheString = buffer.toString();
111: }
112: return cacheString;
113: }
114:
115: // Cloneable implementation --------------------------------------
116: public Object clone() {
117: MBeanParameterInfo clone = null;
118: try {
119: clone = (MBeanParameterInfo) super .clone();
120: clone.type = getType();
121: } catch (CloneNotSupportedException e) {
122: }
123:
124: return clone;
125: }
126: }
|