Class StringLength

    • Field Detail

      • m_Min

        protected Integer m_Min
        the minimum length.
      • m_Max

        protected Integer m_Max
        the maximum length.
    • Constructor Detail

      • StringLength

        public StringLength​(Integer min,
                            Integer max)
        Initializes the constraint.
        Parameters:
        min - the minimum length, null for no limit
        max - the maximum length, null for no limit
      • StringLength

        public StringLength​(AbstractOption owner,
                            Integer min,
                            Integer max)
        Initializes the constraint.
        Parameters:
        owner - the option this constraint is for
        min - the minimum length, null for no limit
        max - the maximum length, null for no limit
    • Method Detail

      • hasMin

        public boolean hasMin()
        Returns whether a lower limit is set.
        Returns:
        true if limit set
      • getMin

        public Integer getMin()
        Returns the lower limit, if any.
        Returns:
        the limit, null if no limit
      • hasMax

        public boolean hasMax()
        Returns whether an upper limit is set.
        Returns:
        true if limit set
      • getMax

        public Integer getMax()
        Returns the upper limit, if any.
        Returns:
        the limit, null if no limit
      • isValidMsg

        public String isValidMsg​(String value)
        Checks the value against the constraints. If it violates the constraints, uses the owner's logger to output a warning message.
        Specified by:
        isValidMsg in class AbstractOptionConstraint<String>
        Parameters:
        value - the value to check
        Returns:
        null if valid otherwise the error message