org.apache.commons.contract.constraints
Class NumberConstraints

java.lang.Object
  extended by org.apache.commons.contract.constraints.NumberConstraints
All Implemented Interfaces:
Castable, Constraints, Validatable

public class NumberConstraints
extends Object
implements Constraints


Field Summary
protected  List allowedValues
           
protected  boolean constrained
           
protected  boolean inclusive
           
protected  Number maximum
           
protected  Number minimum
           
static NumberConstraints NEGATIVE
           
static NumberConstraints POSITIVE
           
static NumberConstraints UNCONSTRAINED
           
 
Constructor Summary
NumberConstraints()
           
NumberConstraints(Number[] allowedValues)
           
NumberConstraints(Number minimum, Number maximum)
           
NumberConstraints(Number minimum, Number maximum, boolean inclusive)
           
 
Method Summary
 void addAllowedValue(Number value)
           
 Object cast(Object value, Context context)
           
 Number[] getAllowedValues()
           
 Number getMaximum()
           
 Number getMinimum()
           
 boolean isConstrained()
           
 void setMaximum(Number maximum)
           
 void setMinimum(Number minimum)
           
 void validate(Object value, Context context)
           
 org.apache.commons.i18n.bundles.TextBundle verboseConstraints()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNCONSTRAINED

public static final NumberConstraints UNCONSTRAINED

POSITIVE

public static final NumberConstraints POSITIVE

NEGATIVE

public static final NumberConstraints NEGATIVE

constrained

protected boolean constrained

inclusive

protected boolean inclusive

allowedValues

protected List allowedValues

minimum

protected Number minimum

maximum

protected Number maximum
Constructor Detail

NumberConstraints

public NumberConstraints()

NumberConstraints

public NumberConstraints(Number minimum,
                         Number maximum)

NumberConstraints

public NumberConstraints(Number minimum,
                         Number maximum,
                         boolean inclusive)

NumberConstraints

public NumberConstraints(Number[] allowedValues)
Method Detail

isConstrained

public boolean isConstrained()

addAllowedValue

public void addAllowedValue(Number value)

getAllowedValues

public Number[] getAllowedValues()

setMinimum

public void setMinimum(Number minimum)

getMinimum

public Number getMinimum()

setMaximum

public void setMaximum(Number maximum)

getMaximum

public Number getMaximum()

cast

public Object cast(Object value,
                   Context context)
            throws CastException
Specified by:
cast in interface Castable
Throws:
CastException

validate

public void validate(Object value,
                     Context context)
              throws ValidationException
Specified by:
validate in interface Validatable
Throws:
ValidationException

verboseConstraints

public org.apache.commons.i18n.bundles.TextBundle verboseConstraints()
Specified by:
verboseConstraints in interface Constraints


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.