private <T> OpenMBeanParameterInfoSupport( String name, String description, OpenType<T> openType, T defaultValue, T[] legalValues, Comparable<T> minValue, Comparable<T> maxValue) throws OpenDataException { super( name, (openType == null) ? null : openType.getClassName(), description, makeDescriptor(openType, defaultValue, legalValues, minValue, maxValue)); this.openType = openType; Descriptor d = getDescriptor(); this.defaultValue = defaultValue; this.minValue = minValue; this.maxValue = maxValue; // We already converted the array into an unmodifiable Set // in the descriptor. this.legalValues = (Set<?>) d.getFieldValue("legalValues"); check(this); }
/** * Constructs an {@code OpenMBeanParameterInfoSupport} instance, which describes the parameter * used in one or more operations or constructors of a class of open MBeans, with the specified * {@code name}, {@code openType}, {@code description}, and {@code descriptor}. * * <p>The {@code descriptor} can contain entries that will define the values returned by certain * methods of this class, as explained in the {@link <a href="package-summary.html#constraints"> * package description</a>}. * * @param name cannot be a null or empty string. * @param description cannot be a null or empty string. * @param openType cannot be null. * @param descriptor The descriptor for the parameter. This may be null which is equivalent to an * empty descriptor. * @throws IllegalArgumentException if {@code name} or {@code description} are null or empty * string, or {@code openType} is null, or the descriptor entries are invalid as described in * the {@link <a href="package-summary.html#constraints">package description</a>}. * @since 1.6 */ public OpenMBeanParameterInfoSupport( String name, String description, OpenType<?> openType, Descriptor descriptor) { // Construct parent's state // super( name, (openType == null) ? null : openType.getClassName(), description, ImmutableDescriptor.union( descriptor, (openType == null) ? null : openType.getDescriptor())); // Initialize this instance's specific state // this.openType = openType; descriptor = getDescriptor(); // replace null by empty this.defaultValue = valueFrom(descriptor, "defaultValue", openType); this.legalValues = valuesFrom(descriptor, "legalValues", openType); this.minValue = comparableValueFrom(descriptor, "minValue", openType); this.maxValue = comparableValueFrom(descriptor, "maxValue", openType); try { check(this); } catch (OpenDataException e) { throw new IllegalArgumentException(e.getMessage(), e); } }