1 19 20 package org.openide.util; 21 22 51 public class Parameters { 52 53 private Parameters() {} 54 55 62 public static void notNull(CharSequence name, Object value) { 63 if (value == null) { 64 throw new NullPointerException ("The " + name + " parameter cannot be null"); } 66 } 67 68 78 public static void notEmpty(CharSequence name, CharSequence value) { 79 notNull(name, value); 80 if (value.length() == 0) { 81 throw new IllegalArgumentException ("The " + name + " parameter cannot be an empty character sequence"); } 83 } 84 85 96 public static void notWhitespace(CharSequence name, CharSequence value) { 97 notNull(name, value); 98 if (value.toString().trim().length() == 0) { 99 throw new IllegalArgumentException ("The " + name + " parameter must contain at least one non-whitespace character"); } 101 } 102 103 113 public static void javaIdentifier(CharSequence name, CharSequence value) { 114 notNull(name, value); 115 javaIdentifierOrNull(name, value); 116 } 117 118 127 public static void javaIdentifierOrNull(CharSequence name, CharSequence value) { 128 if (value != null && !Utilities.isJavaIdentifier(value.toString())) { 129 throw new IllegalArgumentException ("The " + name + " parameter ('" + value + "') is not a valid Java identifier"); } 131 } 132 } 133 | Popular Tags |