jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
equal
deleted
inserted
replaced
76 private final Set<?> legalValues; // to be constructed unmodifiable |
76 private final Set<?> legalValues; // to be constructed unmodifiable |
77 |
77 |
78 /** |
78 /** |
79 * @serial The open mbean attribute's min value |
79 * @serial The open mbean attribute's min value |
80 */ |
80 */ |
81 private final Comparable minValue; |
81 private final Comparable<?> minValue; |
82 |
82 |
83 /** |
83 /** |
84 * @serial The open mbean attribute's max value |
84 * @serial The open mbean attribute's max value |
85 */ |
85 */ |
86 private final Comparable maxValue; |
86 private final Comparable<?> maxValue; |
87 |
87 |
88 |
88 |
89 // As this instance is immutable, these two values need only |
89 // As this instance is immutable, these two values need only |
90 // be calculated once. |
90 // be calculated once. |
91 private transient Integer myHashCode = null; |
91 private transient Integer myHashCode = null; |
448 } else |
448 } else |
449 return this; |
449 return this; |
450 } |
450 } |
451 |
451 |
452 static void check(OpenMBeanParameterInfo info) throws OpenDataException { |
452 static void check(OpenMBeanParameterInfo info) throws OpenDataException { |
453 OpenType openType = info.getOpenType(); |
453 OpenType<?> openType = info.getOpenType(); |
454 if (openType == null) |
454 if (openType == null) |
455 throw new IllegalArgumentException("OpenType cannot be null"); |
455 throw new IllegalArgumentException("OpenType cannot be null"); |
456 |
456 |
457 if (info.getName() == null || |
457 if (info.getName() == null || |
458 info.getName().trim().equals("")) |
458 info.getName().trim().equals("")) |
560 } |
560 } |
561 } |
561 } |
562 |
562 |
563 } |
563 } |
564 |
564 |
565 @SuppressWarnings("unchecked") |
565 @SuppressWarnings({"unchecked", "rawtypes"}) |
566 static int compare(Object x, Object y) { |
566 static int compare(Object x, Object y) { |
567 return ((Comparable) x).compareTo(y); |
567 return ((Comparable) x).compareTo(y); |
568 } |
568 } |
569 |
569 |
570 static <T> Descriptor makeDescriptor(OpenType<T> openType, |
570 static <T> Descriptor makeDescriptor(OpenType<T> openType, |
655 for (Object element : coll) |
655 for (Object element : coll) |
656 result.add(convertFrom(element, openType)); |
656 result.add(convertFrom(element, openType)); |
657 return result; |
657 return result; |
658 } |
658 } |
659 |
659 |
660 static <T> Comparable comparableValueFrom(Descriptor d, String name, |
660 static <T> Comparable<?> comparableValueFrom(Descriptor d, String name, |
661 OpenType<T> openType) { |
661 OpenType<T> openType) { |
662 T t = valueFrom(d, name, openType); |
662 T t = valueFrom(d, name, openType); |
663 if (t == null || t instanceof Comparable<?>) |
663 if (t == null || t instanceof Comparable<?>) |
664 return (Comparable) t; |
664 return (Comparable<?>) t; |
665 final String msg = |
665 final String msg = |
666 "Descriptor field " + name + " with value " + t + |
666 "Descriptor field " + name + " with value " + t + |
667 " is not Comparable"; |
667 " is not Comparable"; |
668 throw new IllegalArgumentException(msg); |
668 throw new IllegalArgumentException(msg); |
669 } |
669 } |
923 */ |
923 */ |
924 public boolean isValue(Object obj) { |
924 public boolean isValue(Object obj) { |
925 return isValue(this, obj); |
925 return isValue(this, obj); |
926 } |
926 } |
927 |
927 |
928 @SuppressWarnings("unchecked") // cast to Comparable |
928 @SuppressWarnings({"unchecked", "rawtypes"}) // cast to Comparable |
929 static boolean isValue(OpenMBeanParameterInfo info, Object obj) { |
929 static boolean isValue(OpenMBeanParameterInfo info, Object obj) { |
930 if (info.hasDefaultValue() && obj == null) |
930 if (info.hasDefaultValue() && obj == null) |
931 return true; |
931 return true; |
932 return |
932 return |
933 info.getOpenType().isValue(obj) && |
933 info.getOpenType().isValue(obj) && |