Package adams.core.option.constraint
Class AbstractOptionConstraint<T>
- java.lang.Object
-
- adams.core.option.constraint.AbstractOptionConstraint<T>
-
- Type Parameters:
T- the option type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NumericBounds,StringLength
public abstract class AbstractOptionConstraint<T> extends Object implements Serializable
Ancestor for constraints for options, e.g., lower/upper bound for numbers.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractOptionm_Ownerthe owner.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOptionConstraint(AbstractOption owner)Initializes the constraint.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description OptionHandlergetOptionHandler()Returns the option handler this option belongs to.OptionManagergetOptionManager()Returns the option manager this option belongs to.AbstractOptiongetOwner()Returns the option this constraint is for.booleanisValid(T value)Checks the value against the constraints.abstract StringisValidMsg(T value)Checks the value against the constraints.voidlogMsg(String msg)Logs the message, either with the owner's logger or just System.err.voidsetOwner(AbstractOption value)Sets the option that this constraint is for.
-
-
-
Field Detail
-
m_Owner
protected AbstractOption m_Owner
the owner.
-
-
Constructor Detail
-
AbstractOptionConstraint
protected AbstractOptionConstraint(AbstractOption owner)
Initializes the constraint.- Parameters:
owner- the option this constraint is for; if null must be set later viasetOwner(AbstractOption)
-
-
Method Detail
-
setOwner
public void setOwner(AbstractOption value)
Sets the option that this constraint is for.- Parameters:
value- the option
-
getOwner
public AbstractOption getOwner()
Returns the option this constraint is for.- Returns:
- the option
-
getOptionManager
public OptionManager getOptionManager()
Returns the option manager this option belongs to.- Returns:
- the owning OptionManager
-
getOptionHandler
public OptionHandler getOptionHandler()
Returns the option handler this option belongs to.- Returns:
- the owning OptionHandler
-
logMsg
public void logMsg(String msg)
Logs the message, either with the owner's logger or just System.err.- Parameters:
msg- the message to log, ignored if null
-
isValid
public boolean isValid(T value)
Checks the value against the constraints. If it violates the constraints, uses the owner's logger to output a warning message.- Parameters:
value- the value to check- Returns:
- true if valid
-
-