2362N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A// OpenMBeanAttributeInfoSupport and this class are very similar 0N/A// but can't easily be refactored because there's no multiple inheritance. 0N/A// The best we can do for refactoring is to put a bunch of static methods 0N/A// in OpenMBeanAttributeInfoSupport and import them here. 0N/A * Describes a parameter used in one or more operations or 0N/A * constructors of an open MBean. 0N/A /* Serial version */ 0N/A * @serial The open mbean parameter's <i>open type</i> 0N/A * @serial The open mbean parameter's default value 0N/A * @serial The open mbean parameter's legal values. This {@link 0N/A * Set} is unmodifiable 0N/A * @serial The open mbean parameter's min value 0N/A * @serial The open mbean parameter's max value 0N/A // As this instance is immutable, these two values need only 0N/A // be calculated once. 0N/A * Constructs an {@code OpenMBeanParameterInfoSupport} instance, 0N/A * which describes the parameter used in one or more operations or 0N/A * constructors of a class of open MBeans, with the specified 0N/A * {@code name}, {@code openType} and {@code description}. 0N/A * @param name cannot be a null or empty string. 0N/A * @param description cannot be a null or empty string. 0N/A * @param openType cannot be null. 0N/A * @throws IllegalArgumentException if {@code name} or {@code 0N/A * description} are null or empty string, or {@code openType} is 0N/A * <p>Constructs an {@code OpenMBeanParameterInfoSupport} instance, 0N/A * which describes the parameter used in one or more operations or 0N/A * constructors of a class of open MBeans, with the specified 0N/A * {@code name}, {@code openType}, {@code description}, 0N/A * and {@code descriptor}.</p> 0N/A * <p>The {@code descriptor} can contain entries that will define 0N/A * the values returned by certain methods of this class, as 0N/A * package description</a>}. 0N/A * @param name cannot be a null or empty string. 0N/A * @param description cannot be a null or empty string. 0N/A * @param openType cannot be null. 0N/A * @param descriptor The descriptor for the parameter. This may be null 0N/A * which is equivalent to an empty descriptor. 0N/A * @throws IllegalArgumentException if {@code name} or {@code 0N/A * description} are null or empty string, or {@code openType} is 0N/A * null, or the descriptor entries are invalid as described in the 0N/A // Construct parent's state 0N/A // Initialize this instance's specific state 0N/A * Constructs an {@code OpenMBeanParameterInfoSupport} instance, 0N/A * which describes the parameter used in one or more operations or 0N/A * constructors of a class of open MBeans, with the specified 0N/A * {@code name}, {@code openType}, {@code description} and {@code 0N/A * @param name cannot be a null or empty string. 0N/A * @param description cannot be a null or empty string. 0N/A * @param openType cannot be null. 0N/A * @param defaultValue must be a valid value for the {@code 0N/A * openType} specified for this parameter; default value not 0N/A * supported for {@code ArrayType} and {@code TabularType}; can be 0N/A * null, in which case it means that no default value is set. 0N/A * @param <T> allows the compiler to check that the {@code defaultValue}, 0N/A * if non-null, has the correct Java type for the given {@code openType}. 0N/A * @throws IllegalArgumentException if {@code name} or {@code 0N/A * description} are null or empty string, or {@code openType} is 0N/A * @throws OpenDataException if {@code defaultValue} is not a 0N/A * valid value for the specified {@code openType}, or {@code 0N/A * defaultValue} is non null and {@code openType} is an {@code 0N/A * ArrayType} or a {@code TabularType}. 0N/A * <p>Constructs an {@code OpenMBeanParameterInfoSupport} instance, 0N/A * which describes the parameter used in one or more operations or 0N/A * constructors of a class of open MBeans, with the specified 0N/A * {@code name}, {@code openType}, {@code description}, {@code 0N/A * defaultValue} and {@code legalValues}.</p> 0N/A * <p>The contents of {@code legalValues} are copied, so subsequent 0N/A * modifications of the array referenced by {@code legalValues} 0N/A * have no impact on this {@code OpenMBeanParameterInfoSupport} 0N/A * @param name cannot be a null or empty string. 0N/A * @param description cannot be a null or empty string. 0N/A * @param openType cannot be null. 0N/A * @param defaultValue must be a valid value for the {@code 0N/A * openType} specified for this parameter; default value not 0N/A * supported for {@code ArrayType} and {@code TabularType}; can be 0N/A * null, in which case it means that no default value is set. 0N/A * @param legalValues each contained value must be valid for the 0N/A * {@code openType} specified for this parameter; legal values not 0N/A * supported for {@code ArrayType} and {@code TabularType}; can be 0N/A * @param <T> allows the compiler to check that the {@code 0N/A * defaultValue} and {@code legalValues}, if non-null, have the 0N/A * correct Java type for the given {@code openType}. 0N/A * @throws IllegalArgumentException if {@code name} or {@code 0N/A * description} are null or empty string, or {@code openType} is 0N/A * @throws OpenDataException if {@code defaultValue} is not a 0N/A * valid value for the specified {@code openType}, or one value in 0N/A * {@code legalValues} is not valid for the specified {@code 0N/A * openType}, or {@code defaultValue} is non null and {@code 0N/A * openType} is an {@code ArrayType} or a {@code TabularType}, or 0N/A * {@code legalValues} is non null and non empty and {@code 0N/A * openType} is an {@code ArrayType} or a {@code TabularType}, or 0N/A * {@code legalValues} is non null and non empty and {@code 0N/A * defaultValue} is not contained in {@code legalValues}. 0N/A * Constructs an {@code OpenMBeanParameterInfoSupport} instance, 0N/A * which describes the parameter used in one or more operations or 0N/A * constructors of a class of open MBeans, with the specified 0N/A * {@code name}, {@code openType}, {@code description}, {@code 0N/A * defaultValue}, {@code minValue} and {@code maxValue}. 0N/A * It is possible to specify minimal and maximal values only for 0N/A * an open type whose values are {@code Comparable}. 0N/A * @param name cannot be a null or empty string. 0N/A * @param description cannot be a null or empty string. 0N/A * @param openType cannot be null. 0N/A * @param defaultValue must be a valid value for the {@code 0N/A * openType} specified for this parameter; default value not 0N/A * supported for {@code ArrayType} and {@code TabularType}; can be 0N/A * null, in which case it means that no default value is set. 0N/A * @param minValue must be valid for the {@code openType} 0N/A * specified for this parameter; can be null, in which case it 0N/A * means that no minimal value is set. 0N/A * @param maxValue must be valid for the {@code openType} 0N/A * specified for this parameter; can be null, in which case it 0N/A * means that no maximal value is set. 0N/A * @param <T> allows the compiler to check that the {@code 0N/A * defaultValue}, {@code minValue}, and {@code maxValue}, if 0N/A * non-null, have the correct Java type for the given {@code 0N/A * @throws IllegalArgumentException if {@code name} or {@code 0N/A * description} are null or empty string, or {@code openType} is 0N/A * @throws OpenDataException if {@code defaultValue}, {@code 0N/A * minValue} or {@code maxValue} is not a valid value for the 0N/A * specified {@code openType}, or {@code defaultValue} is non null 0N/A * and {@code openType} is an {@code ArrayType} or a {@code 0N/A * TabularType}, or both {@code minValue} and {@code maxValue} are 0N/A * non-null and {@code minValue.compareTo(maxValue) > 0} is {@code 0N/A * true}, or both {@code defaultValue} and {@code minValue} are 0N/A * non-null and {@code minValue.compareTo(defaultValue) > 0} is 0N/A * {@code true}, or both {@code defaultValue} and {@code maxValue} 0N/A * are non-null and {@code defaultValue.compareTo(maxValue) > 0} 0N/A // We already converted the array into an unmodifiable Set 0N/A // in the descriptor. 0N/A * An object serialized in a version of the API before Descriptors were 0N/A * added to this class will have an empty or null Descriptor. 0N/A * For consistency with our 0N/A * behavior in this version, we must replace the object with one 0N/A * where the Descriptors reflect the same values of openType, defaultValue, 0N/A // This noise allows us to avoid "unchecked" warnings without 0N/A // having to suppress them explicitly. 0N/A * Returns the open type for the values of the parameter described 0N/A * by this {@code OpenMBeanParameterInfoSupport} instance. 0N/A * Returns the default value for the parameter described by this 0N/A * {@code OpenMBeanParameterInfoSupport} instance, if specified, 0N/A * or {@code null} otherwise. 0N/A // Special case for ArrayType and TabularType 0N/A // [JF] TODO: clone it so that it cannot be altered, 0N/A // [JF] TODO: if we decide to support defaultValue as an array itself. 0N/A // [JF] As of today (oct 2000) it is not supported so 0N/A // defaultValue is null for arrays. Nothing to do. 0N/A * Returns an unmodifiable Set of legal values for the parameter 0N/A * described by this {@code OpenMBeanParameterInfoSupport} 0N/A * instance, if specified, or {@code null} otherwise. 0N/A // Special case for ArrayType and TabularType 0N/A // [JF] TODO: clone values so that they cannot be altered, 0N/A // [JF] TODO: if we decide to support LegalValues as an array itself. 0N/A // [JF] As of today (oct 2000) it is not supported so 0N/A // legalValues is null for arrays. Nothing to do. 0N/A // Returns our legalValues Set (set was constructed unmodifiable) 0N/A * Returns the minimal value for the parameter described by this 0N/A * {@code OpenMBeanParameterInfoSupport} instance, if specified, 0N/A * or {@code null} otherwise. 0N/A // Note: only comparable values have a minValue, so that's not 0N/A // the case of arrays and tabulars (always null). 0N/A * Returns the maximal value for the parameter described by this 0N/A * {@code OpenMBeanParameterInfoSupport} instance, if specified, 0N/A * or {@code null} otherwise. 0N/A // Note: only comparable values have a maxValue, so that's not 0N/A // the case of arrays and tabulars (always null). 0N/A * Returns {@code true} if this {@code 0N/A * OpenMBeanParameterInfoSupport} instance specifies a non-null 0N/A * default value for the described parameter, {@code false} 0N/A * Returns {@code true} if this {@code 0N/A * OpenMBeanParameterInfoSupport} instance specifies a non-null 0N/A * set of legal values for the described parameter, {@code false} 0N/A * Returns {@code true} if this {@code 0N/A * OpenMBeanParameterInfoSupport} instance specifies a non-null 0N/A * minimal value for the described parameter, {@code false} 0N/A * Returns {@code true} if this {@code 0N/A * OpenMBeanParameterInfoSupport} instance specifies a non-null 0N/A * maximal value for the described parameter, {@code false} 0N/A * Tests whether {@code obj} is a valid value for the parameter 0N/A * described by this {@code OpenMBeanParameterInfo} instance. 0N/A * @param obj the object to be tested. 0N/A * @return {@code true} if {@code obj} is a valid value 0N/A * for the parameter described by this 0N/A * {@code OpenMBeanParameterInfo} instance, 0N/A * {@code false} otherwise. 0N/A // compiler bug? should be able to omit class name here 0N/A // also below in toString and hashCode 0N/A /* *** Commodity methods from java.lang.Object *** */ 0N/A * <p>Compares the specified {@code obj} parameter with this {@code 0N/A * OpenMBeanParameterInfoSupport} instance for equality.</p> 0N/A * <p>Returns {@code true} if and only if all of the following 0N/A * statements are true: 0N/A * <li>{@code obj} is non null,</li> 0N/A * <li>{@code obj} also implements the {@code OpenMBeanParameterInfo} 0N/A * <li>their names are equal</li> 0N/A * <li>their open types are equal</li> 0N/A * <li>their default, min, max and legal values are equal.</li> 0N/A * This ensures that this {@code equals} method works properly for 0N/A * {@code obj} parameters which are different implementations of 0N/A * the {@code OpenMBeanParameterInfo} interface. 0N/A * <p>If {@code obj} also implements {@link DescriptorRead}, then its 0N/A * {@link DescriptorRead#getDescriptor() getDescriptor()} method must 0N/A * also return the same value as for this object.</p> 0N/A * @param obj the object to be compared for equality with this 0N/A * {@code OpenMBeanParameterInfoSupport} instance. 0N/A * @return {@code true} if the specified object is equal to this 0N/A * {@code OpenMBeanParameterInfoSupport} instance. 0N/A * <p>Returns the hash code value for this {@code 0N/A * OpenMBeanParameterInfoSupport} instance.</p> 0N/A * <p>The hash code of an {@code OpenMBeanParameterInfoSupport} 0N/A * instance is the sum of the hash codes of all elements of 0N/A * information used in {@code equals} comparisons (ie: its name, 0N/A * its <i>open type</i>, its default, min, max and legal 0N/A * values, and its Descriptor). 0N/A * <p>This ensures that {@code t1.equals(t2)} implies that {@code 0N/A * t1.hashCode()==t2.hashCode()} for any two {@code 0N/A * OpenMBeanParameterInfoSupport} instances {@code t1} and {@code 0N/A * t2}, as required by the general contract of the method {@link 0N/A * Object#hashCode() Object.hashCode()}. 0N/A * <p>However, note that another instance of a class implementing 0N/A * the {@code OpenMBeanParameterInfo} interface may be equal to 0N/A * this {@code OpenMBeanParameterInfoSupport} instance as defined 0N/A * by {@link #equals(java.lang.Object)}, but may have a different 0N/A * hash code if it is calculated differently. 0N/A * <p>As {@code OpenMBeanParameterInfoSupport} instances are 0N/A * immutable, the hash code for this instance is calculated once, 0N/A * on the first call to {@code hashCode}, and then the same value 0N/A * is returned for subsequent calls. 0N/A * @return the hash code value for this {@code 0N/A * OpenMBeanParameterInfoSupport} instance 0N/A // Calculate the hash code value if it has not yet been done 0N/A // (ie 1st call to hashCode()) 0N/A // return always the same hash code for this instance (immutable) 0N/A * Returns a string representation of this 0N/A * {@code OpenMBeanParameterInfoSupport} instance. 0N/A * The string representation consists of the name of this class (i.e. 0N/A * {@code javax.management.openmbean.OpenMBeanParameterInfoSupport}), 0N/A * the string representation of the name and open type of the described 0N/A * parameter, the string representation of its default, min, max and legal 0N/A * values and the string representation of its descriptor. 0N/A * As {@code OpenMBeanParameterInfoSupport} instances are immutable, 0N/A * the string representation for this instance is calculated once, 0N/A * on the first call to {@code toString}, and then the same value 0N/A * is returned for subsequent calls. 0N/A * @return a string representation of this 0N/A * {@code OpenMBeanParameterInfoSupport} instance. 0N/A // Calculate the string value if it has not yet been done (ie 0N/A // 1st call to toString()) 0N/A // return always the same string representation for this 0N/A // instance (immutable)