com.googlecode.kevinarpe.papaya.argument
Class DateTimeIterableArgs

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

public class DateTimeIterableArgs
extends Object

Static methods to check Iterable<DateTime> arguments.

See ObjectArgs for an overview.

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

Method Summary
static
<TIterable extends Iterable<DateTime>>
TIterable
checkExactValue(TIterable iterable, DateTime exactValue, String iterableArgName)
          Tests if all values in an Iterable have an exact value.
static
<TIterable extends Iterable<DateTime>>
TIterable
checkMaxValue(TIterable iterable, DateTime maxValue, String iterableArgName)
          Tests if all values in an Iterable have a maximum value.
static
<TIterable extends Iterable<DateTime>>
TIterable
checkMinValue(TIterable iterable, DateTime minValue, String iterableArgName)
          Tests if all values in an Iterable have a minimum value.
static
<TIterable extends Iterable<DateTime>>
TIterable
checkNotExactValue(TIterable iterable, DateTime exactValue, String iterableArgName)
          Tests if all values in an Iterable do not have an exact value.
static
<TIterable extends Iterable<DateTime>>
TIterable
checkValueInsideRange(TIterable iterable, DateTime minValue, DateTime maxValue, String iterableArgName)
          Tests if all values in an Iterable are within specified range.
static
<TIterable extends Iterable<DateTime>>
TIterable
checkValueOutsideRange(TIterable iterable, DateTime minValue, DateTime maxValue, String iterableArgName)
          Tests if all values in an Iterable 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 <TIterable extends Iterable<DateTime>> TIterable checkValueInsideRange(TIterable iterable,
                                                                                                 DateTime minValue,
                                                                                                 DateTime maxValue,
                                                                                                 String iterableArgName)
Tests if all values in an Iterable are within specified range.

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

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

checkValueOutsideRange

@FullyTested
public static <TIterable extends Iterable<DateTime>> TIterable checkValueOutsideRange(TIterable iterable,
                                                                                                  DateTime minValue,
                                                                                                  DateTime maxValue,
                                                                                                  String iterableArgName)
Tests if all values in an Iterable are not within specified range.

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

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

checkMinValue

@FullyTested
public static <TIterable extends Iterable<DateTime>> TIterable checkMinValue(TIterable iterable,
                                                                                         DateTime minValue,
                                                                                         String iterableArgName)
Tests if all values in an Iterable have a minimum value.

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

checkMaxValue

@FullyTested
public static <TIterable extends Iterable<DateTime>> TIterable checkMaxValue(TIterable iterable,
                                                                                         DateTime maxValue,
                                                                                         String iterableArgName)
Tests if all values in an Iterable have a maximum value.

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

checkExactValue

@FullyTested
public static <TIterable extends Iterable<DateTime>> TIterable checkExactValue(TIterable iterable,
                                                                                           DateTime exactValue,
                                                                                           String iterableArgName)
Tests if all values in an Iterable have an exact value.

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

checkNotExactValue

@FullyTested
public static <TIterable extends Iterable<DateTime>> TIterable checkNotExactValue(TIterable iterable,
                                                                                              DateTime exactValue,
                                                                                              String iterableArgName)
Tests if all values in an Iterable do not have an exact value.

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


Copyright © 2013-2014. All Rights Reserved.