1. /*
  2. * @(#)MBeanParameterInfo.java 1.24 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management;
  8. /**
  9. * Describes an argument of an operation exposed by an MBean.
  10. * Instances of this class are immutable. Subclasses may be mutable
  11. * but this is not recommended.
  12. *
  13. * @since 1.5
  14. */
  15. public class MBeanParameterInfo extends MBeanFeatureInfo implements java.io.Serializable, Cloneable {
  16. /* Serial version */
  17. static final long serialVersionUID = 7432616882776782338L;
  18. /* All zero-length arrays are interchangeable. */
  19. static final MBeanParameterInfo[] NO_PARAMS = new MBeanParameterInfo[0];
  20. /**
  21. * @serial The type or class name of the data.
  22. */
  23. private final String type;
  24. /**
  25. * Constructs a <CODE>MBeanParameterInfo</CODE> object.
  26. *
  27. * @param name The name of the data
  28. * @param type The type or class name of the data
  29. * @param description A human readable description of the data. Optional.
  30. */
  31. public MBeanParameterInfo(String name,
  32. String type,
  33. String description)
  34. throws IllegalArgumentException {
  35. super(name, description);
  36. this.type = type;
  37. }
  38. /**
  39. * <p>Returns a shallow clone of this instance.
  40. * The clone is obtained by simply calling <tt>super.clone()</tt>,
  41. * thus calling the default native shallow cloning mechanism
  42. * implemented by <tt>Object.clone()</tt>.
  43. * No deeper cloning of any internal field is made.</p>
  44. *
  45. * <p>Since this class is immutable, cloning is chiefly of
  46. * interest to subclasses.</p>
  47. */
  48. public Object clone () {
  49. try {
  50. return super.clone() ;
  51. } catch (CloneNotSupportedException e) {
  52. // should not happen as this class is cloneable
  53. return null;
  54. }
  55. }
  56. /**
  57. * Returns the type or class name of the data.
  58. *
  59. * @return the type string.
  60. */
  61. public String getType() {
  62. return type;
  63. }
  64. /**
  65. * Compare this MBeanParameterInfo to another.
  66. *
  67. * @param o the object to compare to.
  68. *
  69. * @return true iff <code>o</code> is an MBeanParameterInfo such
  70. * that its {@link #getName()}, {@link #getType()}, and {@link
  71. * #getDescription()} values are equal (not necessarily identical)
  72. * to those of this MBeanParameterInfo.
  73. */
  74. public boolean equals(Object o) {
  75. if (o == this)
  76. return true;
  77. if (!(o instanceof MBeanParameterInfo))
  78. return false;
  79. MBeanParameterInfo p = (MBeanParameterInfo) o;
  80. return (p.getName().equals(getName()) &&
  81. p.getType().equals(getType()) &&
  82. p.getDescription().equals(getDescription()));
  83. }
  84. public int hashCode() {
  85. return getName().hashCode() ^ getType().hashCode();
  86. }
  87. }