Class ConstraintField


  • public class ConstraintField
    extends Field
    ConstraintField class represents a single Field and constraints on its values; Field name and its scope are inherited from the Field class.
    • Method Detail

      • setCacheOnMatch

        public void setCacheOnMatch​(boolean cacheOnMatch)
        set whether to cache should the constraints check pass
        Parameters:
        cacheOnMatch - should the constraint check pass, should we cache?
      • getCacheOnMatch

        public boolean getCacheOnMatch()
        Returns:
        cache-on-match setting
      • setCacheOnMatchFailure

        public void setCacheOnMatchFailure​(boolean cacheOnMatchFailure)
        set whether to cache should there be a failure forcing the constraint
        Parameters:
        cacheOnMatchFailure - should there be a constraint check failure, enable cache?
      • getCacheOnMatchFailure

        public boolean getCacheOnMatchFailure()
        Returns:
        cache-on-match-failure setting
      • addConstraint

        public void addConstraint​(ValueConstraint constraint)
        add a constraint for this field
        Parameters:
        constraint - one constraint associated with this field
      • setValueConstraints

        public void setValueConstraints​(ValueConstraint[] vcs)
        add an array of constraints for this field
        Parameters:
        vcs - constraints associated with this field
      • applyConstraints

        public boolean applyConstraints​(jakarta.servlet.ServletContext context,
                                        jakarta.servlet.http.HttpServletRequest request)
        apply the constraints on the value of the field in the given request. return a true if all the constraints pass; false when the field is not found or the field value doesn't pass the caching constraints.