1. /*
  2. * @(#)MBeanFeatureInfo.java 1.22 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. * <p>Provides general information for an MBean descriptor object.
  10. * The feature described can be an attribute, an operation, a
  11. * parameter, or a notification. Instances of this class are
  12. * immutable. Subclasses may be mutable but this is not
  13. * recommended.</p>
  14. *
  15. * @since 1.5
  16. */
  17. public class MBeanFeatureInfo implements java.io.Serializable {
  18. /* Serial version */
  19. static final long serialVersionUID = 3952882688968447265L;
  20. /**
  21. * The name of the feature. It is recommended that subclasses call
  22. * {@link #getName} rather than reading this field, and that they
  23. * not change it.
  24. *
  25. * @serial The name of the feature.
  26. */
  27. protected String name;
  28. /**
  29. * The human-readable description of the feature. It is
  30. * recommended that subclasses call {@link #getDescription} rather
  31. * than reading this field, and that they not change it.
  32. *
  33. * @serial The human-readable description of the feature.
  34. */
  35. protected String description;
  36. /**
  37. * Constructs an <CODE>MBeanFeatureInfo</CODE> object.
  38. *
  39. * @param name The name of the feature.
  40. * @param description A human readable description of the feature.
  41. */
  42. public MBeanFeatureInfo(String name, String description)
  43. throws IllegalArgumentException {
  44. this.name = name;
  45. this.description = description;
  46. }
  47. /**
  48. * Returns the name of the feature.
  49. *
  50. * @return the name of the feature.
  51. */
  52. public String getName() {
  53. return name;
  54. }
  55. /**
  56. * Returns the human-readable description of the feature.
  57. *
  58. * @return the human-readable description of the feature.
  59. */
  60. public String getDescription() {
  61. return description;
  62. }
  63. /**
  64. * Compare this MBeanFeatureInfo to another.
  65. *
  66. * @param o the object to compare to.
  67. *
  68. * @return true iff <code>o</code> is an MBeanFeatureInfo such
  69. * that its {@link #getName()} and {@link #getDescription()}
  70. * values are equal (not necessarily identical) to those of this
  71. * MBeanFeatureInfo.
  72. */
  73. public boolean equals(Object o) {
  74. if (o == this)
  75. return true;
  76. if (!(o instanceof MBeanFeatureInfo))
  77. return false;
  78. MBeanFeatureInfo p = (MBeanFeatureInfo) o;
  79. return (p.getName().equals(getName()) &&
  80. p.getDescription().equals(getDescription()));
  81. }
  82. public int hashCode() {
  83. return getName().hashCode() ^ getDescription().hashCode();
  84. }
  85. }