< prev index next >

src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 439         if (getDescriptor().getFieldNames().length == 0) {
 440             OpenType<Object> xopenType = cast(openType);
 441             Set<Object> xlegalValues = cast(legalValues);
 442             Comparable<Object> xminValue = cast(minValue);
 443             Comparable<Object> xmaxValue = cast(maxValue);
 444             return new OpenMBeanAttributeInfoSupport(
 445                     name, description, openType,
 446                     isReadable(), isWritable(), isIs(),
 447                     makeDescriptor(xopenType, defaultValue, xlegalValues,
 448                                    xminValue, xmaxValue));
 449         } else
 450             return this;
 451     }
 452 
 453     static void check(OpenMBeanParameterInfo info) throws OpenDataException {
 454         OpenType<?> openType = info.getOpenType();
 455         if (openType == null)
 456             throw new IllegalArgumentException("OpenType cannot be null");
 457 
 458         if (info.getName() == null ||
 459                 info.getName().trim().equals(""))
 460             throw new IllegalArgumentException("Name cannot be null or empty");
 461 
 462         if (info.getDescription() == null ||
 463                 info.getDescription().trim().equals(""))
 464             throw new IllegalArgumentException("Description cannot be null or empty");
 465 
 466         // Check and initialize defaultValue
 467         //
 468         if (info.hasDefaultValue()) {
 469             // Default value not supported for ArrayType and TabularType
 470             // Cast to Object because "OpenType<T> instanceof" is illegal
 471             if (openType.isArray() || (Object)openType instanceof TabularType) {
 472                 throw new OpenDataException("Default value not supported " +
 473                                             "for ArrayType and TabularType");
 474             }
 475             // Check defaultValue's class
 476             if (!openType.isValue(info.getDefaultValue())) {
 477                 final String msg =
 478                     "Argument defaultValue's class [\"" +
 479                     info.getDefaultValue().getClass().getName() +
 480                     "\"] does not match the one defined in openType[\"" +
 481                     openType.getClassName() +"\"]";
 482                 throw new OpenDataException(msg);
 483             }




 439         if (getDescriptor().getFieldNames().length == 0) {
 440             OpenType<Object> xopenType = cast(openType);
 441             Set<Object> xlegalValues = cast(legalValues);
 442             Comparable<Object> xminValue = cast(minValue);
 443             Comparable<Object> xmaxValue = cast(maxValue);
 444             return new OpenMBeanAttributeInfoSupport(
 445                     name, description, openType,
 446                     isReadable(), isWritable(), isIs(),
 447                     makeDescriptor(xopenType, defaultValue, xlegalValues,
 448                                    xminValue, xmaxValue));
 449         } else
 450             return this;
 451     }
 452 
 453     static void check(OpenMBeanParameterInfo info) throws OpenDataException {
 454         OpenType<?> openType = info.getOpenType();
 455         if (openType == null)
 456             throw new IllegalArgumentException("OpenType cannot be null");
 457 
 458         if (info.getName() == null ||
 459                 info.getName().trim().isEmpty())
 460             throw new IllegalArgumentException("Name cannot be null or empty");
 461 
 462         if (info.getDescription() == null ||
 463                 info.getDescription().trim().isEmpty())
 464             throw new IllegalArgumentException("Description cannot be null or empty");
 465 
 466         // Check and initialize defaultValue
 467         //
 468         if (info.hasDefaultValue()) {
 469             // Default value not supported for ArrayType and TabularType
 470             // Cast to Object because "OpenType<T> instanceof" is illegal
 471             if (openType.isArray() || (Object)openType instanceof TabularType) {
 472                 throw new OpenDataException("Default value not supported " +
 473                                             "for ArrayType and TabularType");
 474             }
 475             // Check defaultValue's class
 476             if (!openType.isValue(info.getDefaultValue())) {
 477                 final String msg =
 478                     "Argument defaultValue's class [\"" +
 479                     info.getDefaultValue().getClass().getName() +
 480                     "\"] does not match the one defined in openType[\"" +
 481                     openType.getClassName() +"\"]";
 482                 throw new OpenDataException(msg);
 483             }


< prev index next >