Package adams.core.option.constraint
Class NumericBounds<T extends Number>
- java.lang.Object
-
- adams.core.option.constraint.AbstractOptionConstraint<T>
-
- adams.core.option.constraint.NumericBounds<T>
-
- All Implemented Interfaces:
Serializable
public class NumericBounds<T extends Number> extends AbstractOptionConstraint<T>
Constraint that enforces lower/upper bounds for numeric values.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Tm_LowerBoundthe lower bound.protected Tm_UpperBoundthe upper bound.-
Fields inherited from class adams.core.option.constraint.AbstractOptionConstraint
m_Owner
-
-
Constructor Summary
Constructors Constructor Description NumericBounds(AbstractOption owner, T lowerBound, T upperBound)Initializes the constraint.NumericBounds(T lowerBound, T upperBound)Initializes the constraint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TcheckBounds(T number)Checks whether the number is within the specified bounds (if any).TgetLowerBound()Returns the lower bound for this option.TgetUpperBound()Returns the lower bound for this option.booleanhasLowerBound()Checks whether a lower bound has been defined for this option.booleanhasUpperBound()Checks whether a lower bound has been defined for this option.StringisValidMsg(Number value)Checks the value against the constraints.-
Methods inherited from class adams.core.option.constraint.AbstractOptionConstraint
getOptionHandler, getOptionManager, getOwner, isValid, logMsg, setOwner
-
-
-
-
Constructor Detail
-
NumericBounds
public NumericBounds(T lowerBound, T upperBound)
Initializes the constraint.- Parameters:
lowerBound- the lower bound, can be nullupperBound- the upper bound, can be null
-
NumericBounds
public NumericBounds(AbstractOption owner, T lowerBound, T upperBound)
Initializes the constraint.- Parameters:
owner- the option this constraint is forlowerBound- the lower bound, can be nullupperBound- the upper bound, can be null
-
-
Method Detail
-
hasLowerBound
public boolean hasLowerBound()
Checks whether a lower bound has been defined for this option.- Returns:
- true if lower bound exists
-
getLowerBound
public T getLowerBound()
Returns the lower bound for this option.- Returns:
- the lower bound, can be null if none defined
-
hasUpperBound
public boolean hasUpperBound()
Checks whether a lower bound has been defined for this option.- Returns:
- true if lower bound exists
-
getUpperBound
public T getUpperBound()
Returns the lower bound for this option.- Returns:
- the lower bound, can be null if none defined
-
isValidMsg
public String isValidMsg(Number value)
Checks the value against the constraints. If it violates the constraints, uses the owner's logger to output a warning message.- Specified by:
isValidMsgin classAbstractOptionConstraint<T extends Number>- Parameters:
value- the value to check- Returns:
- null if valid otherwise the error message
-
-