Class 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
    • Constructor Detail

      • AbstractOptionConstraint

        protected AbstractOptionConstraint​(AbstractOption owner)
        Initializes the constraint.
        Parameters:
        owner - the option this constraint is for; if null must be set later via setOwner(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
      • isValidMsg

        public abstract String isValidMsg​(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:
        null if valid otherwise the error message