Lines Matching refs:value

85      * Ensures that that the argument numeric value is non-negative.
87 * @param value a numeric int value
89 * @return the validated numeric value
90 * @throws IllegalArgumentException if {@code value} was negative
92 public static int checkArgumentNonnegative(final int value, final String errorMessage) {
93 if (value < 0) {
97 return value;
101 * Ensures that that the argument numeric value is non-negative.
103 * @param value a numeric long value
105 * @return the validated numeric value
106 * @throws IllegalArgumentException if {@code value} was negative
108 public static long checkArgumentNonnegative(final long value, final String errorMessage) {
109 if (value < 0) {
113 return value;
117 * Ensures that that the argument numeric value is positive.
119 * @param value a numeric int value
121 * @return the validated numeric value
122 * @throws IllegalArgumentException if {@code value} was not positive
124 public static int checkArgumentPositive(final int value, final String errorMessage) {
125 if (value <= 0) {
129 return value;
133 * Ensures that the argument floating point value is a finite number.
138 * @param value a floating point value
141 * @return the validated floating point value
143 * @throws IllegalArgumentException if {@code value} was not finite
145 public static float checkArgumentFinite(final float value, final String valueName) {
146 if (Float.isNaN(value)) {
148 } else if (Float.isInfinite(value)) {
152 return value;
156 * Ensures that the argument floating point value is within the inclusive range.
161 * @param value a floating point value
166 * @return the validated floating point value
168 * @throws IllegalArgumentException if {@code value} was not within the range
170 public static float checkArgumentInRange(float value, float lower, float upper,
172 if (Float.isNaN(value)) {
174 } else if (value < lower) {
178 } else if (value > upper) {
184 return value;
188 * Ensures that the argument int value is within the inclusive range.
190 * @param value a int value
195 * @return the validated int value
197 * @throws IllegalArgumentException if {@code value} was not within the range
199 public static int checkArgumentInRange(int value, int lower, int upper,
201 if (value < lower) {
205 } else if (value > upper) {
211 return value;
217 * @param value an array of boxed objects
222 * @throws NullPointerException if the {@code value} or any of its elements were {@code null}
224 public static <T> T[] checkArrayElementsNotNull(final T[] value, final String valueName) {
225 if (value == null) {
229 for (int i = 0; i < value.length; ++i) {
230 if (value[i] == null) {
236 return value;
243 * @param value a {@link Collection} of boxed objects
248 * @throws NullPointerException if the {@code value} or any of its elements were {@code null}
250 public static <T> Collection<T> checkCollectionElementsNotNull(final Collection<T> value,
252 if (value == null) {
257 for (T elem : value) {
265 return value;
271 * @param value a {@link Collection} of boxed elements.
276 * @throws NullPointerException if the {@code value} was {@code null}
277 * @throws IllegalArgumentException if the {@code value} was empty
279 public static <T> Collection<T> checkCollectionNotEmpty(final Collection<T> value,
281 if (value == null) {
284 if (value.isEmpty()) {
287 return value;
296 * @param value a floating point array of values
301 * @return the validated floating point value
303 * @throws IllegalArgumentException if any of the elements in {@code value} were out of range
304 * @throws NullPointerException if the {@code value} was {@code null}
306 public static float[] checkArrayElementsInRange(float[] value, float lower, float upper,
308 checkNotNull(value, valueName + " must not be null");
310 for (int i = 0; i < value.length; ++i) {
311 float v = value[i];
326 return value;