Class ValidationOverrides

  • Direct Known Subclasses:
    ValidationOverrides.AllowAllValidationOverrides

    public class ValidationOverrides
    extends java.lang.Object
    A set of allows which suppresses specific validations in limited time periods. This is useful to be able to complete a deployment in cases where the application owner believes that the changes to be deployed have acceptable consequences. Immutable.
    Author:
    bratseth
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean allows​(ValidationId validationId, java.time.Instant now)
      Returns whether the given (assumed invalid) change is allowed by this at the moment
      boolean allows​(java.lang.String validationIdString, java.time.Instant now)  
      static ValidationOverrides fromXml​(java.io.Reader reader)
      Returns a ValidationOverrides instance with the content of the given Reader.
      static ValidationOverrides fromXml​(java.lang.String xmlForm)
      Returns a ValidationOverrides instance with the content of the given XML string.
      void invalid​(ValidationId validationId, java.lang.String message, java.time.Instant now)
      Throws a ValidationException unless this validation is overridden at this time
      void invalid​(java.util.Map<ValidationId,​? extends java.util.Collection<java.lang.String>> messagesByValidationId, java.time.Instant now)
      Throws a ValidationException unless all given validation is overridden at this time
      static java.lang.String toAllowMessage​(ValidationId id)  
      java.lang.String xmlForm()
      Returns the XML form of this, or null if it was not created by fromXml, nor is empty
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • all

        public static final ValidationOverrides all
        A special instance which behaves as if it contained a valid allow override for every (valid) validation id
    • Constructor Detail

      • ValidationOverrides

        public ValidationOverrides​(java.util.List<ValidationOverrides.Allow> overrides)
        Creates a validation overrides which does not have an xml form
    • Method Detail

      • invalid

        public void invalid​(java.util.Map<ValidationId,​? extends java.util.Collection<java.lang.String>> messagesByValidationId,
                            java.time.Instant now)
        Throws a ValidationException unless all given validation is overridden at this time
      • invalid

        public void invalid​(ValidationId validationId,
                            java.lang.String message,
                            java.time.Instant now)
        Throws a ValidationException unless this validation is overridden at this time
      • allows

        public boolean allows​(java.lang.String validationIdString,
                              java.time.Instant now)
      • allows

        public boolean allows​(ValidationId validationId,
                              java.time.Instant now)
        Returns whether the given (assumed invalid) change is allowed by this at the moment
      • xmlForm

        public java.lang.String xmlForm()
        Returns the XML form of this, or null if it was not created by fromXml, nor is empty
      • toAllowMessage

        public static java.lang.String toAllowMessage​(ValidationId id)
      • fromXml

        public static ValidationOverrides fromXml​(java.io.Reader reader)
        Returns a ValidationOverrides instance with the content of the given Reader.
        Parameters:
        reader - the reader containing a validation-overrides XML structure
        Returns:
        a ValidationOverrides from the argument
        Throws:
        java.lang.IllegalArgumentException - if the validation-allows.xml file exists but is invalid
      • fromXml

        public static ValidationOverrides fromXml​(java.lang.String xmlForm)
        Returns a ValidationOverrides instance with the content of the given XML string. An empty ValidationOverrides is returned if the argument is empty.
        Parameters:
        xmlForm - the string which optionally contains a validation-overrides XML structure
        Returns:
        a ValidationOverrides from the argument
        Throws:
        java.lang.IllegalArgumentException - if the validation-allows.xml file exists but is invalid