Class ValidationResult
- java.lang.Object
-
- com.hybris.cockpitng.core.model.impl.AbstractObservable
-
- com.hybris.cockpitng.validation.model.ValidationResult
-
- All Implemented Interfaces:
Observable
public class ValidationResult extends AbstractObservable
-
-
Field Summary
Fields Modifier and Type Field Description static ValidationResultEMPTY-
Fields inherited from class com.hybris.cockpitng.core.model.impl.AbstractObservable
mutex
-
-
Constructor Summary
Constructors Modifier Constructor Description ValidationResult()Creates empty validation resultprotectedValidationResult(ValidationInfoFactory infoFactory, boolean dirty, java.util.List<ValidationInfo> result)ValidationResult(java.util.List<ValidationInfo> result)Creates validation result with root validation violations as specifiedValidationResult(java.util.List<ValidationInfo> result, java.lang.String prefix, boolean withPrefix)Creates validation result with or without given prefix
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddValidationInfo(ValidationInfo info)Adds new validation violation to current container.voidaddValidationInfo(java.lang.String path, java.util.Collection<ValidationInfo> validationInfos)Adds new validation violations to current container.protected booleancheckDirty()Checks whether container is sorted.voidclear()Removes all validation violations registered in current container.booleancontains(java.lang.String path)Checks whether container contains any validation violation for specified path.booleancontainsNotConfirmedSeverity(ValidationSeverity severity)Checks whether container contains any validation violation with specified severity that is not confirmed.booleancontainsSeverity(ValidationSeverity severity)Checks whether container contains any validation violation with specified severity.protected java.util.List<ValidationInfo>createResultList(java.util.List<ValidationInfo> init)protected ValidationInfoFactorycreateWithoutPrefixFactory(java.lang.String prefix)protected ValidationInfoFactorycreateWithPrefixFactory(java.lang.String prefix)booleanequals(java.lang.Object o)ValidationResultSetfind(java.lang.String path)Gets all validation violations contained by this container that are related to specified path or it's subpaths.ValidationResultSetfindNotConfirmed(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.ValidationResultSetget(ValidationSeverity severity)Gets all validation violations contained by this container that has specified severity level.ValidationResultSetget(java.lang.String prefix)Gets all validation violations contained by this container that are related to specified prefix or it's subpaths.java.util.List<ValidationInfo>getAll()Gets all validation violations that are contained by this container.ValidationResultSetgetConfirmed()Gets all validation violations contained by this container that are confirmed.ValidationSeveritygetHighestNotConfirmedSeverity()Gets highest severity of violations contained by container that are not confirmed.ValidationInfogetHighestNotConfirmedSeverityInfo()Gets violation with highest severity of violations contained by container that are not confirmed.ValidationSeveritygetHighestSeverity()Gets highest severity of violations contained by container.ValidationInfogetHighestSeverityInfo()Gets violation with highest severity of violations contained by container.ValidationResultSetgetNotConfirmed()Gets all validation violations contained by this container that are not confirmed.ValidationResultSetgetNotConfirmed(ValidationSeverity severity)Gets all validation violations contained by this container that has specified severity level are not confirmed.ValidationResultSetgetNotConfirmed(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.protected java.util.stream.Stream<ValidationInfo>getNotConfirmedStream(java.lang.String path)protected java.util.stream.Stream<ValidationInfo>getStream(java.lang.String path)inthashCode()protected booleanisDirty()Checks whether container is sorted.protected voidmarkDirty()Marks container as unsortedprotected booleanpathsMatches(java.lang.String expected, java.lang.String actual)Checks whether provided paths matchesprotected voidremoveImmediately(java.lang.String path)voidremoveValidationInfo(ValidationInfo info)Removes validation violation from current containervoidremoveValidationInfo(java.lang.String path)Removes all validation violations from specified path and its subpaths from current container with provided.voidsetValidationInfo(java.lang.String path, java.util.Collection<ValidationInfo> validationInfos)Replaces violations related to provided path with their new instances.voidsetValidationInfo(java.util.Collection<ValidationInfo> validationInfos)Replaces all validation violations registered in current container with provided.intsize()Gets number of violations contained by this containervoidupdateValidationInfo(java.lang.String path, java.util.Collection<ValidationInfo> validationInfos)Replaces violations with their new instances.voidupdateValidationInfo(java.util.Collection<ValidationInfo> validationInfos)Replaces violations with their new instances.-
Methods inherited from class com.hybris.cockpitng.core.model.impl.AbstractObservable
addObserver, alreadyExists, changed, changed, getObservedValues, getObservers, removeObserver, removeObserver
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.hybris.cockpitng.core.model.Observable
addObserver
-
-
-
-
Field Detail
-
EMPTY
public static final ValidationResult EMPTY
-
-
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 factorydirty-trueif provided violations are not sortedresult- root violations
-
-
Method Detail
-
createResultList
protected java.util.List<ValidationInfo> createResultList(java.util.List<ValidationInfo> init)
-
checkDirty
protected boolean checkDirty()
Checks whether container is sorted. If then, then all violations are being sorted descending by their severity.- Returns:
trueif container was just sorted
-
markDirty
protected void markDirty()
Marks container as unsorted
-
isDirty
protected boolean isDirty()
Checks whether container is sorted.- Returns:
trueif 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 expectedactual- path found in violation- Returns:
trueif 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
-
getHighestSeverity
public ValidationSeverity getHighestSeverity()
Gets highest severity of violations contained by container.- Returns:
- highest severity or
ValidationSeverity.NONEif container is empty
-
getHighestSeverityInfo
public ValidationInfo getHighestSeverityInfo()
Gets violation with highest severity of violations contained by container.- Returns:
- violation with highest severity or
nullif container is empty
-
getHighestNotConfirmedSeverity
public ValidationSeverity getHighestNotConfirmedSeverity()
Gets highest severity of violations contained by container that are not confirmed.- Returns:
- highest severity or
ValidationSeverity.NONEif 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
nullif container is empty
-
containsSeverity
public boolean containsSeverity(ValidationSeverity severity)
Checks whether container contains any validation violation with specified severity.- Parameters:
severity- violations severity- Returns:
trueif 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:
trueif 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:
trueif 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 violationsvalidationInfos- 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 violationsvalidationInfos- 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 changedvalidationInfos- new violations- Throws:
java.lang.IllegalArgumentException- if any of provided violation defines a path that is not relative topath- 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-