J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | package javax.management.openmbean; |
| 28 | |
| 29 | |
| 30 | // java import |
| 31 | // |
| 32 | import java.util.Set; |
| 33 | import java.lang.Comparable; // to be substituted for jdk1.1.x |
| 34 | |
| 35 | |
| 36 | // jmx import |
| 37 | // |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * <p>Describes a parameter used in one or more operations or |
| 42 | * constructors of an open MBean.</p> |
| 43 | * |
| 44 | * <p>This interface declares the same methods as the class {@link |
| 45 | * javax.management.MBeanParameterInfo}. A class implementing this |
| 46 | * interface (typically {@link OpenMBeanParameterInfoSupport}) should |
| 47 | * extend {@link javax.management.MBeanParameterInfo}.</p> |
| 48 | * |
| 49 | * |
| 50 | * @since 1.5 |
| 51 | */ |
| 52 | public interface OpenMBeanParameterInfo { |
| 53 | |
| 54 | |
| 55 | // Re-declares methods that are in class MBeanParameterInfo of JMX 1.0 |
| 56 | // (these will be removed when MBeanParameterInfo is made a parent interface of this interface) |
| 57 | |
| 58 | /** |
| 59 | * Returns a human readable description of the parameter |
| 60 | * described by this <tt>OpenMBeanParameterInfo</tt> instance. |
| 61 | * |
| 62 | * @return the description. |
| 63 | */ |
| 64 | public String getDescription() ; |
| 65 | |
| 66 | /** |
| 67 | * Returns the name of the parameter |
| 68 | * described by this <tt>OpenMBeanParameterInfo</tt> instance. |
| 69 | * |
| 70 | * @return the name. |
| 71 | */ |
| 72 | public String getName() ; |
| 73 | |
| 74 | |
| 75 | // Now declares methods that are specific to open MBeans |
| 76 | // |
| 77 | |
| 78 | /** |
| 79 | * Returns the <i>open type</i> of the values of the parameter |
| 80 | * described by this <tt>OpenMBeanParameterInfo</tt> instance. |
| 81 | * |
| 82 | * @return the open type. |
| 83 | */ |
| 84 | public OpenType<?> getOpenType() ; |
| 85 | |
| 86 | /** |
| 87 | * Returns the default value for this parameter, if it has one, or |
| 88 | * <tt>null</tt> otherwise. |
| 89 | * |
| 90 | * @return the default value. |
| 91 | */ |
| 92 | public Object getDefaultValue() ; |
| 93 | |
| 94 | /** |
| 95 | * Returns the set of legal values for this parameter, if it has |
| 96 | * one, or <tt>null</tt> otherwise. |
| 97 | * |
| 98 | * @return the set of legal values. |
| 99 | */ |
| 100 | public Set<?> getLegalValues() ; |
| 101 | |
| 102 | /** |
| 103 | * Returns the minimal value for this parameter, if it has one, or |
| 104 | * <tt>null</tt> otherwise. |
| 105 | * |
| 106 | * @return the minimum value. |
| 107 | */ |
| 108 | public Comparable<?> getMinValue() ; |
| 109 | |
| 110 | /** |
| 111 | * Returns the maximal value for this parameter, if it has one, or |
| 112 | * <tt>null</tt> otherwise. |
| 113 | * |
| 114 | * @return the maximum value. |
| 115 | */ |
| 116 | public Comparable<?> getMaxValue() ; |
| 117 | |
| 118 | /** |
| 119 | * Returns <tt>true</tt> if this parameter has a specified default |
| 120 | * value, or <tt>false</tt> otherwise. |
| 121 | * |
| 122 | * @return true if there is a default value. |
| 123 | */ |
| 124 | public boolean hasDefaultValue() ; |
| 125 | |
| 126 | /** |
| 127 | * Returns <tt>true</tt> if this parameter has a specified set of |
| 128 | * legal values, or <tt>false</tt> otherwise. |
| 129 | * |
| 130 | * @return true if there is a set of legal values. |
| 131 | */ |
| 132 | public boolean hasLegalValues() ; |
| 133 | |
| 134 | /** |
| 135 | * Returns <tt>true</tt> if this parameter has a specified minimal |
| 136 | * value, or <tt>false</tt> otherwise. |
| 137 | * |
| 138 | * @return true if there is a minimum value. |
| 139 | */ |
| 140 | public boolean hasMinValue() ; |
| 141 | |
| 142 | /** |
| 143 | * Returns <tt>true</tt> if this parameter has a specified maximal |
| 144 | * value, or <tt>false</tt> otherwise. |
| 145 | * |
| 146 | * @return true if there is a maximum value. |
| 147 | */ |
| 148 | public boolean hasMaxValue() ; |
| 149 | |
| 150 | /** |
| 151 | * Tests whether <var>obj</var> is a valid value for the parameter |
| 152 | * described by this <code>OpenMBeanParameterInfo</code> instance. |
| 153 | * |
| 154 | * @param obj the object to be tested. |
| 155 | * |
| 156 | * @return <code>true</code> if <var>obj</var> is a valid value |
| 157 | * for the parameter described by this |
| 158 | * <code>OpenMBeanParameterInfo</code> instance, |
| 159 | * <code>false</code> otherwise. |
| 160 | */ |
| 161 | public boolean isValue(Object obj) ; |
| 162 | |
| 163 | |
| 164 | /** |
| 165 | * Compares the specified <var>obj</var> parameter with this <code>OpenMBeanParameterInfo</code> instance for equality. |
| 166 | * <p> |
| 167 | * Returns <tt>true</tt> if and only if all of the following statements are true: |
| 168 | * <ul> |
| 169 | * <li><var>obj</var> is non null,</li> |
| 170 | * <li><var>obj</var> also implements the <code>OpenMBeanParameterInfo</code> interface,</li> |
| 171 | * <li>their names are equal</li> |
| 172 | * <li>their open types are equal</li> |
| 173 | * <li>their default, min, max and legal values are equal.</li> |
| 174 | * </ul> |
| 175 | * This ensures that this <tt>equals</tt> method works properly for <var>obj</var> parameters which are |
| 176 | * different implementations of the <code>OpenMBeanParameterInfo</code> interface. |
| 177 | * <br> |
| 178 | * @param obj the object to be compared for equality with this <code>OpenMBeanParameterInfo</code> instance; |
| 179 | * |
| 180 | * @return <code>true</code> if the specified object is equal to this <code>OpenMBeanParameterInfo</code> instance. |
| 181 | */ |
| 182 | public boolean equals(Object obj); |
| 183 | |
| 184 | /** |
| 185 | * Returns the hash code value for this <code>OpenMBeanParameterInfo</code> instance. |
| 186 | * <p> |
| 187 | * The hash code of an <code>OpenMBeanParameterInfo</code> instance is the sum of the hash codes |
| 188 | * of all elements of information used in <code>equals</code> comparisons |
| 189 | * (ie: its name, its <i>open type</i>, and its default, min, max and legal values). |
| 190 | * <p> |
| 191 | * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code> |
| 192 | * for any two <code>OpenMBeanParameterInfo</code> instances <code>t1</code> and <code>t2</code>, |
| 193 | * as required by the general contract of the method |
| 194 | * {@link Object#hashCode() Object.hashCode()}. |
| 195 | * <p> |
| 196 | * |
| 197 | * @return the hash code value for this <code>OpenMBeanParameterInfo</code> instance |
| 198 | */ |
| 199 | public int hashCode(); |
| 200 | |
| 201 | /** |
| 202 | * Returns a string representation of this <code>OpenMBeanParameterInfo</code> instance. |
| 203 | * <p> |
| 204 | * The string representation consists of the name of this class (ie <code>javax.management.openmbean.OpenMBeanParameterInfo</code>), |
| 205 | * the string representation of the name and open type of the described parameter, |
| 206 | * and the string representation of its default, min, max and legal values. |
| 207 | * |
| 208 | * @return a string representation of this <code>OpenMBeanParameterInfo</code> instance |
| 209 | */ |
| 210 | public String toString(); |
| 211 | |
| 212 | } |