< prev index next >

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

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


 107      * @throws IllegalArgumentException if {@code name} or {@code
 108      * description} are null or empty string.
 109      *
 110      * @throws ArrayStoreException If {@code signature} is not an
 111      * array of instances of a subclass of {@code MBeanParameterInfo}.
 112      *
 113      * @since 1.6
 114      */
 115     public OpenMBeanConstructorInfoSupport(String name,
 116                                            String description,
 117                                            OpenMBeanParameterInfo[] signature,
 118                                            Descriptor descriptor) {
 119         super(name,
 120               description,
 121               arrayCopyCast(signature), // may throw an ArrayStoreException
 122               descriptor);
 123 
 124         // check parameters that should not be null or empty
 125         // (unfortunately it is not done in superclass :-( ! )
 126         //
 127         if (name == null || name.trim().equals("")) {
 128             throw new IllegalArgumentException("Argument name cannot be " +
 129                                                "null or empty");
 130         }
 131         if (description == null || description.trim().equals("")) {
 132             throw new IllegalArgumentException("Argument description cannot " +
 133                                                "be null or empty");
 134         }
 135 
 136     }
 137 
 138     private static MBeanParameterInfo[]
 139             arrayCopyCast(OpenMBeanParameterInfo[] src) {
 140         if (src == null)
 141             return null;
 142 
 143         MBeanParameterInfo[] dst = new MBeanParameterInfo[src.length];
 144         System.arraycopy(src, 0, dst, 0, src.length);
 145         // may throw an ArrayStoreException
 146         return dst;
 147     }
 148 
 149 
 150     /* ***  Commodity methods from java.lang.Object  *** */
 151 




 107      * @throws IllegalArgumentException if {@code name} or {@code
 108      * description} are null or empty string.
 109      *
 110      * @throws ArrayStoreException If {@code signature} is not an
 111      * array of instances of a subclass of {@code MBeanParameterInfo}.
 112      *
 113      * @since 1.6
 114      */
 115     public OpenMBeanConstructorInfoSupport(String name,
 116                                            String description,
 117                                            OpenMBeanParameterInfo[] signature,
 118                                            Descriptor descriptor) {
 119         super(name,
 120               description,
 121               arrayCopyCast(signature), // may throw an ArrayStoreException
 122               descriptor);
 123 
 124         // check parameters that should not be null or empty
 125         // (unfortunately it is not done in superclass :-( ! )
 126         //
 127         if (name == null || name.trim().isEmpty()) {
 128             throw new IllegalArgumentException("Argument name cannot be " +
 129                                                "null or empty");
 130         }
 131         if (description == null || description.trim().isEmpty()) {
 132             throw new IllegalArgumentException("Argument description cannot " +
 133                                                "be null or empty");
 134         }
 135 
 136     }
 137 
 138     private static MBeanParameterInfo[]
 139             arrayCopyCast(OpenMBeanParameterInfo[] src) {
 140         if (src == null)
 141             return null;
 142 
 143         MBeanParameterInfo[] dst = new MBeanParameterInfo[src.length];
 144         System.arraycopy(src, 0, dst, 0, src.length);
 145         // may throw an ArrayStoreException
 146         return dst;
 147     }
 148 
 149 
 150     /* ***  Commodity methods from java.lang.Object  *** */
 151 


< prev index next >