1/*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. 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.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26
27package javax.management.openmbean;
28
29
30// java import
31//
32import java.util.Set;
33import 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 */
52public 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 {@code OpenMBeanParameterInfo} instance.
61     *
62     * @return the description.
63     */
64    public String getDescription() ;
65
66    /**
67     * Returns the name of the parameter
68     * described by this {@code OpenMBeanParameterInfo} 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 {@code OpenMBeanParameterInfo} 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     * {@code null} 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 {@code null} 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     * {@code null} 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     * {@code null} otherwise.
113     *
114     * @return the maximum value.
115     */
116    public Comparable<?> getMaxValue() ;
117
118    /**
119     * Returns {@code true} if this parameter has a specified default
120     * value, or {@code false} otherwise.
121     *
122     * @return true if there is a default value.
123     */
124    public boolean hasDefaultValue() ;
125
126    /**
127     * Returns {@code true} if this parameter has a specified set of
128     * legal values, or {@code false} otherwise.
129     *
130     * @return true if there is a set of legal values.
131     */
132    public boolean hasLegalValues() ;
133
134    /**
135     * Returns {@code true} if this parameter has a specified minimal
136     * value, or {@code false} otherwise.
137     *
138     * @return true if there is a minimum value.
139     */
140    public boolean hasMinValue() ;
141
142    /**
143     * Returns {@code true} if this parameter has a specified maximal
144     * value, or {@code false} 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} instance.
153     *
154     * @param obj the object to be tested.
155     *
156     * @return {@code true} if <var>obj</var> is a valid value
157     * for the parameter described by this
158     * {@code OpenMBeanParameterInfo} instance,
159     * {@code false} otherwise.
160     */
161    public boolean isValue(Object obj) ;
162
163
164    /**
165     * Compares the specified <var>obj</var> parameter with this {@code OpenMBeanParameterInfo} instance for equality.
166     * <p>
167     * Returns {@code true} 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} 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 {@code equals} method works properly for <var>obj</var> parameters which are
176     * different implementations of the {@code OpenMBeanParameterInfo} interface.
177     * <br>&nbsp;
178     * @param  obj  the object to be compared for equality with this {@code OpenMBeanParameterInfo} instance;
179     *
180     * @return  {@code true} if the specified object is equal to this {@code OpenMBeanParameterInfo} instance.
181     */
182    public boolean equals(Object obj);
183
184    /**
185     * Returns the hash code value for this {@code OpenMBeanParameterInfo} instance.
186     * <p>
187     * The hash code of an {@code OpenMBeanParameterInfo} instance is the sum of the hash codes
188     * of all elements of information used in {@code equals} 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)} implies that {@code t1.hashCode()==t2.hashCode()}
192     * for any two {@code OpenMBeanParameterInfo} instances {@code t1} and {@code t2},
193     * as required by the general contract of the method
194     * {@link Object#hashCode() Object.hashCode()}.
195     *
196     * @return  the hash code value for this {@code OpenMBeanParameterInfo} instance
197     */
198    public int hashCode();
199
200    /**
201     * Returns a string representation of this {@code OpenMBeanParameterInfo} instance.
202     * <p>
203     * The string representation consists of the name of this class (ie {@code javax.management.openmbean.OpenMBeanParameterInfo}),
204     * the string representation of the name and open type of the described parameter,
205     * and the string representation of its default, min, max and legal values.
206     *
207     * @return  a string representation of this {@code OpenMBeanParameterInfo} instance
208     */
209    public String toString();
210
211}
212