Class ValidationResult

    • Constructor Detail

      • ValidationResult

        public ValidationResult()
        Creates empty validation result
      • ValidationResult

        public ValidationResult​(java.util.List<ValidationInfo> result,
                                java.lang.String prefix,
                                boolean withPrefix)
        Creates validation result with or without given prefix
      • ValidationResult

        public ValidationResult​(java.util.List<ValidationInfo> result)
        Creates validation result with root validation violations as specified
        Parameters:
        result - root violations
      • ValidationResult

        protected ValidationResult​(ValidationInfoFactory infoFactory,
                                   boolean dirty,
                                   java.util.List<ValidationInfo> result)
        Parameters:
        infoFactory - root info factory
        dirty - true if provided violations are not sorted
        result - root violations
    • Method Detail

      • checkDirty

        protected boolean checkDirty()
        Checks whether container is sorted. If then, then all violations are being sorted descending by their severity.
        Returns:
        true if container was just sorted
      • markDirty

        protected void markDirty()
        Marks container as unsorted
      • isDirty

        protected boolean isDirty()
        Checks whether container is sorted.
        Returns:
        true if container need to be sorted
        See Also:
        checkDirty()
      • size

        public int size()
        Gets number of violations contained by this container
        Returns:
        number of contained violations
      • getAll

        public java.util.List<ValidationInfo> getAll()
        Gets all validation violations that are contained by this container. Violations remain as relative to containers root.
        Returns:
        all validation violations from container
      • get

        public ValidationResultSet get​(ValidationSeverity severity)
        Gets all validation violations contained by this container that has specified severity level. Violations remain as relative to containers root.
        Parameters:
        severity - requested severity level
        Returns:
        search result
      • getNotConfirmed

        public ValidationResultSet getNotConfirmed()
        Gets all validation violations contained by this container that are not confirmed. Violations remain as relative to containers root.
        Returns:
        search result
      • getConfirmed

        public ValidationResultSet getConfirmed()
        Gets all validation violations contained by this container that are confirmed. Violations remain as relative to containers root.
        Returns:
        search result
      • getNotConfirmed

        public ValidationResultSet getNotConfirmed​(ValidationSeverity severity)
        Gets all validation violations contained by this container that has specified severity level are not confirmed. Violations remain as relative to containers root.
        Parameters:
        severity - requested severity level
        Returns:
        search result
      • pathsMatches

        protected boolean pathsMatches​(java.lang.String expected,
                                       java.lang.String actual)
        Checks whether provided paths matches
        Parameters:
        expected - path that is expected
        actual - path found in violation
        Returns:
        true if violation path is equal to expected or it's subpath
      • createWithPrefixFactory

        protected ValidationInfoFactory createWithPrefixFactory​(java.lang.String prefix)
      • createWithoutPrefixFactory

        protected ValidationInfoFactory createWithoutPrefixFactory​(java.lang.String prefix)
      • getStream

        protected java.util.stream.Stream<ValidationInfo> getStream​(java.lang.String path)
      • get

        public ValidationResultSet get​(java.lang.String prefix)
        Gets all validation violations contained by this container that are related to specified prefix or it's subpaths. Violations returned are relative to provided prefix.
        Parameters:
        prefix - violations path
        Returns:
        search result
      • find

        public ValidationResultSet find​(java.lang.String path)
        Gets all validation violations contained by this container that are related to specified path or it's subpaths. Violations remain as relative to containers root.
        Parameters:
        path - violations path
        Returns:
        search result
      • getNotConfirmedStream

        protected java.util.stream.Stream<ValidationInfo> getNotConfirmedStream​(java.lang.String path)
      • getNotConfirmed

        public ValidationResultSet getNotConfirmed​(java.lang.String path)
        Gets all validation violations contained by this container that are related to specified path or it's subpaths and are not confirmed. Violations returned are relative to provided path.
        Parameters:
        path - violations path
        Returns:
        search result
      • findNotConfirmed

        public ValidationResultSet findNotConfirmed​(java.lang.String path)
        Gets all validation violations contained by this container that are related to specified path or it's subpaths and are not confirmed. Violations remain as relative to containers root.
        Parameters:
        path - violations path
        Returns:
        search result
      • getHighestSeverityInfo

        public ValidationInfo getHighestSeverityInfo()
        Gets violation with highest severity of violations contained by container.
        Returns:
        violation with highest severity or null if container is empty
      • getHighestNotConfirmedSeverity

        public ValidationSeverity getHighestNotConfirmedSeverity()
        Gets highest severity of violations contained by container that are not confirmed.
        Returns:
        highest severity or ValidationSeverity.NONE if container is empty
      • getHighestNotConfirmedSeverityInfo

        public ValidationInfo getHighestNotConfirmedSeverityInfo()
        Gets violation with highest severity of violations contained by container that are not confirmed.
        Returns:
        violation with highest severity or null if container is empty
      • containsSeverity

        public boolean containsSeverity​(ValidationSeverity severity)
        Checks whether container contains any validation violation with specified severity.
        Parameters:
        severity - violations severity
        Returns:
        true if at least one violation is of specified severity
      • containsNotConfirmedSeverity

        public boolean containsNotConfirmedSeverity​(ValidationSeverity severity)
        Checks whether container contains any validation violation with specified severity that is not confirmed.
        Parameters:
        severity - violations severity
        Returns:
        true if at least one violation is of specified severity and is not confirmed
      • contains

        public boolean contains​(java.lang.String path)
        Checks whether container contains any validation violation for specified path.
        Parameters:
        path - violations path
        Returns:
        true if at least one violation is related to provided path or any of its children
      • addValidationInfo

        public void addValidationInfo​(java.lang.String path,
                                      java.util.Collection<ValidationInfo> validationInfos)
        Adds new validation violations to current container. All violation are considered to be relative containers root and specified path.
        Parameters:
        path - relative path for added violations
        validationInfos - validation violations to be added
      • addValidationInfo

        public void addValidationInfo​(ValidationInfo info)
        Adds new validation violation to current container. violation is considered to be relative containers root.
        Parameters:
        info - validation violation to be added
      • removeImmediately

        protected void removeImmediately​(java.lang.String path)
      • clear

        public void clear()
        Removes all validation violations registered in current container.
      • setValidationInfo

        public void setValidationInfo​(java.util.Collection<ValidationInfo> validationInfos)
        Replaces all validation violations registered in current container with provided.
        Parameters:
        validationInfos - new violations for container
        See Also:
        updateValidationInfo(Collection)
      • setValidationInfo

        public void setValidationInfo​(java.lang.String path,
                                      java.util.Collection<ValidationInfo> validationInfos)
        Replaces violations related to provided path with their new instances. All new violation are considered to be relative to provided root path and prefix is added to them.

        As first all violation related to provided path are removed. Then new violations are wrapped with prefix and added to container.

        Parameters:
        path - root path for added violations
        validationInfos - validation violations to be added
        See Also:
        updateValidationInfo(String, Collection)
      • updateValidationInfo

        public void updateValidationInfo​(java.util.Collection<ValidationInfo> validationInfos)
        Replaces violations with their new instances.

        As first all violations related to same paths that new ones are removed. Then new violations are added to container.

        Notice that only violations related to paths from provided violations are changed, though method does nothing, if provided list is empty.

        Parameters:
        validationInfos - new violations
        See Also:
        removeValidationInfo(String), setValidationInfo(Collection)
      • updateValidationInfo

        public void updateValidationInfo​(java.lang.String path,
                                         java.util.Collection<ValidationInfo> validationInfos)
        Replaces violations with their new instances.

        As first all violation related to provided path are removed. Then new violations are added to container. New violations should be related to provided path and define their violation path as a subpath of it.

        Parameters:
        path - root path which violations are being changed
        validationInfos - new violations
        Throws:
        java.lang.IllegalArgumentException - if any of provided violation defines a path that is not relative to path
        See Also:
        removeValidationInfo(String), setValidationInfo(String, Collection)
      • removeValidationInfo

        public void removeValidationInfo​(java.lang.String path)
        Removes all validation violations from specified path and its subpaths from current container with provided.
        Parameters:
        path - relative path for which to remove violations
      • removeValidationInfo

        public void removeValidationInfo​(ValidationInfo info)
        Removes validation violation from current container
        Parameters:
        info - violation to be removed
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object