com.googlecode.kevinarpe.papaya.argument
Class DateTimeArrayArgs

java.lang.Object
  extended by com.googlecode.kevinarpe.papaya.argument.DateTimeArrayArgs

public class DateTimeArrayArgs
extends Object

Static methods to check DateTime[] arguments.

See ObjectArgs for an overview.

Author:
Kevin Connor ARPE (kevinarpe@gmail.com)

Method Summary
static DateTime[] checkExactValue(DateTime[] arr, DateTime exactValue, String arrArgName)
          Tests if all values in an array have an exact value.
static DateTime[] checkMaxValue(DateTime[] arr, DateTime maxValue, String arrArgName)
          Tests if all values in an array have a maximum value.
static DateTime[] checkMinValue(DateTime[] arr, DateTime minValue, String arrArgName)
          Tests if all values in an array have a minimum value.
static DateTime[] checkNotExactValue(DateTime[] arr, DateTime exactValue, String arrArgName)
          Tests if all values in an array do not have an exact value.
static DateTime[] checkValueInsideRange(DateTime[] arr, DateTime minRangeValue, DateTime maxRangeValue, String arrArgName)
          Tests if all values in an array are within specified range.
static DateTime[] checkValueOutsideRange(DateTime[] arr, DateTime minRangeValue, DateTime maxRangeValue, String arrArgName)
          Tests if all values in an array are not within specified range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkValueInsideRange

@FullyTested
public static DateTime[] checkValueInsideRange(DateTime[] arr,
                                                           DateTime minRangeValue,
                                                           DateTime maxRangeValue,
                                                           String arrArgName)
Tests if all values in an array are within specified range.

Example: All values must be >= 3 and <= 7:
checkValueInsideRange(numbersArray, 3, 7, "numbersArray");

Parameters:
arr - array of values to test. May be empty
minRangeValue - minimum value (inclusive) for inclusive range of each value in array to test
maxRangeValue - maximum value (inclusive) for inclusive range of each value in array to test
arrArgName - argument name for arr, e.g., "valueList"
Returns:
the validated array
Throws:
NullPointerException - if arr is null
IllegalArgumentException -
  • if minValue > maxValue
  • if any value of arr is outside allowed range
See Also:
checkValueInsideRange(DateTime[], DateTime, DateTime, String), DateTimeIterableArgs.checkValueInsideRange(Iterable, DateTime, DateTime, String)

checkValueOutsideRange

@FullyTested
public static DateTime[] checkValueOutsideRange(DateTime[] arr,
                                                            DateTime minRangeValue,
                                                            DateTime maxRangeValue,
                                                            String arrArgName)
Tests if all values in an array are not within specified range.

Example: All values must be <= 3 and >= 7:
checkValueInsideRange(numbersArray, 4, 6, "numbersArray");

Parameters:
arr - array of values to test. May be empty
minRangeValue - minimum value (inclusive) for exclusive range of each value in array to test
maxRangeValue - maximum value (inclusive) for exclusive range of each value in array to test
arrArgName - argument name for arr, e.g., "valueList"
Returns:
the validated array
Throws:
NullPointerException - if arr is null
IllegalArgumentException -
  • if minValue > maxValue
  • if any value of arr is inside not-allowed range
See Also:
checkValueOutsideRange(DateTime[], DateTime, DateTime, String), DateTimeIterableArgs.checkValueOutsideRange(Iterable, DateTime, DateTime, String)

checkMinValue

@FullyTested
public static DateTime[] checkMinValue(DateTime[] arr,
                                                   DateTime minValue,
                                                   String arrArgName)
Tests if all values in an array have a minimum value.

Parameters:
arr - array of values to test. May be empty
minValue - minimum value (inclusive)
arrArgName - argument name for arr, e.g., "valueList"
Returns:
the validated array
Throws:
NullPointerException - if arr is null
IllegalArgumentException - if any value of arr is less than minValue
See Also:
checkMinValue(DateTime[], DateTime, String), DateTimeIterableArgs.checkMinValue(Iterable, DateTime, String)

checkMaxValue

@FullyTested
public static DateTime[] checkMaxValue(DateTime[] arr,
                                                   DateTime maxValue,
                                                   String arrArgName)
Tests if all values in an array have a maximum value.

Parameters:
arr - array of values to test. May be empty
maxValue - maximum value (inclusive)
arrArgName - argument name for arr, e.g., "valueList"
Returns:
the validated array
Throws:
NullPointerException - if arr is null
IllegalArgumentException - if any value of arr is greater than maxValue
See Also:
checkMaxValue(DateTime[], DateTime, String), DateTimeIterableArgs.checkMaxValue(Iterable, DateTime, String)

checkExactValue

@FullyTested
public static DateTime[] checkExactValue(DateTime[] arr,
                                                     DateTime exactValue,
                                                     String arrArgName)
Tests if all values in an array have an exact value.

Parameters:
arr - array of values to test. May be empty
exactValue - expected value
arrArgName - argument name for arr, e.g., "valueList"
Returns:
the validated array
Throws:
NullPointerException - if arr is null
IllegalArgumentException - if any value of arr is not exactValue
See Also:
checkExactValue(DateTime[], DateTime, String), DateTimeIterableArgs.checkExactValue(Iterable, DateTime, String)

checkNotExactValue

@FullyTested
public static DateTime[] checkNotExactValue(DateTime[] arr,
                                                        DateTime exactValue,
                                                        String arrArgName)
Tests if all values in an array do not have an exact value.

Parameters:
arr - array of values to test. May be empty
exactValue - expected value
arrArgName - argument name for arr, e.g., "valueList"
Returns:
the validated array
Throws:
NullPointerException - if arr (or any element) is null
IllegalArgumentException - if any value of arr is exactValue
See Also:
checkNotExactValue(DateTime[], DateTime, String), DateTimeIterableArgs.checkNotExactValue(Iterable, DateTime, String)


Copyright © 2013-2014. All Rights Reserved.