jargs.gnu.validator
Class IntervalValidator<E extends java.lang.Comparable<E>>

java.lang.Object
  extended by jargs.gnu.validator.AbstractValidator<E>
      extended by jargs.gnu.validator.IntervalValidator<E>

public class IntervalValidator<E extends java.lang.Comparable<E>>
extends AbstractValidator<E>

Simple validator that checks if a given Comparable is in the interval of accepted values.

Author:
Philipp Eichhorn

Constructor Summary
IntervalValidator(E min, E max)
          Constructs an IntervalValidator.
 
Method Summary
 E getMax()
          Returns the maximum of the interval or null if no maximum was defined.
 E getMin()
          Returns the minimum of the interval or null if no minimum was defined.
 java.lang.String toString()
           
 boolean validate(E value)
          Override to validate if an command-line option has a expected value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntervalValidator

public IntervalValidator(E min,
                         E max)
Constructs an IntervalValidator.

Parameters:
min - minimum of the interval
max - maximum of the interval
Method Detail

getMin

public E getMin()
Returns the minimum of the interval or null if no minimum was defined.

Returns:
minimum of the interval

getMax

public E getMax()
Returns the maximum of the interval or null if no maximum was defined.

Returns:
maximum of the interval

validate

public boolean validate(E value)
Description copied from class: AbstractValidator
Override to validate if an command-line option has a expected value.

Specified by:
validate in class AbstractValidator<E extends java.lang.Comparable<E>>
Parameters:
value - The Value extracted via an command-line option.
Returns:
true if the value was valid, else false.

toString

public java.lang.String toString()
Overrides:
toString in class AbstractValidator<E extends java.lang.Comparable<E>>