1 25 26 package org.objectweb.petals.util; 27 28 34 public final class ParameterCheckHelper { 35 36 private static final String MUST_NOT_BE_EMPTY = " must not be empty"; 37 38 private static final String MUST_NOT_BE_NULL = " must not be null"; 39 40 private ParameterCheckHelper() { 41 } 43 44 54 public static void isEmptyParameter(String parameter, String parameterName) 55 throws IllegalArgumentException { 56 if (parameter != null 57 && parameter.length() == 0) { 58 throw new IllegalArgumentException (parameterName 59 + MUST_NOT_BE_EMPTY); 60 } 61 } 62 63 76 public static void isEmptyParameterWithLog(String parameter, 77 String parameterName, LoggingUtil log) throws IllegalArgumentException { 78 if (parameter != null 79 && parameter.length() == 0) { 80 log.error(parameterName 81 + MUST_NOT_BE_EMPTY); 82 throw new IllegalArgumentException (parameterName 83 + MUST_NOT_BE_EMPTY); 84 } 85 } 86 87 97 public static void isNullParameter(Object parameter, String parameterName) 98 throws IllegalArgumentException { 99 if (parameter == null) { 100 throw new IllegalArgumentException (parameterName 101 + MUST_NOT_BE_NULL); 102 } 103 } 104 105 117 public static void isNullParameterWithLog(Object parameter, 118 String parameterName, LoggingUtil log) throws IllegalArgumentException { 119 if (parameter == null) { 120 log.error(parameterName 121 + MUST_NOT_BE_NULL); 122 throw new IllegalArgumentException (parameterName 123 + MUST_NOT_BE_NULL); 124 } 125 } 126 127 } 128 | Popular Tags |