Package org.incenp.obofoundry.sssom
Class Validator
java.lang.Object
org.incenp.obofoundry.sssom.Validator
Helper class to validate MappingSet and Mapping objects.
This class is primarily intended to be used internally by the parsers for post-parsing validation, to ensure that the parsed objects are compliant with the requirements from the SSSOM specification. However it may also be used independently of the parsers, for example to validate a set that was constructed ex nihilo.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance.Validator
(ValidationLevel validationLevel) Creates a new instance with the specified validation level. -
Method Summary
Modifier and TypeMethodDescriptionvoid
check
(MappingSet ms) Checks whether the given mapping set is valid, and throws an exception if it is not.Gets the minimum version of the SSSOM specification that the given set is compliant with.Deprecated.validate
(MappingSet ms) Checks whether the given mapping set, including the mappings it contains, is valid.validate
(MappingSet ms, boolean alwaysCheckMappings) Checks whether the given mapping set is valid.
-
Constructor Details
-
Validator
public Validator()Creates a new instance. -
Validator
Creates a new instance with the specified validation level.- Parameters:
validationLevel
- Indicates which checks should be performed.
-
-
Method Details
-
validate
Checks whether the given mapping set, including the mappings it contains, is valid.- Parameters:
ms
- The mapping set to validate.- Returns:
- A set of all the validation errors encountered when checking the mapping set (will be empty if the mapping set is in fact valid).
-
validate
Checks whether the given mapping set is valid.This method allows to skip checking the individual mappings if the set itself is invalid.
- Parameters:
ms
- The mapping set to validate.alwaysCheckMappings
- Iftrue
, individual mappings will always be checked; otherwise, they will be checked only if there are no errors already at the level of the mapping set.- Returns:
- A set of all the validation errors encountered when checking the mapping set (will be empty if the mapping set is in fact valid).
-
check
Checks whether the given mapping set is valid, and throws an exception if it is not.- Parameters:
ms
- The mapping set to validate.- Throws:
SSSOMFormatException
- If the mapping set is invalid.
-
validate
Deprecated.Usevalidate(MappingSet)
to validate an entire mapping set instead.Validates an individual mapping. This method checks that the slots that are required by the specification are present and non-empty.- Parameters:
mapping
- The mapping to validate.- Returns:
- An error message if the mapping is invalid, otherwise
null
.
-
getCompliantVersion
Gets the minimum version of the SSSOM specification that the given set is compliant with.FIXME: This does not really have anything to do with “validation”, so this class may not be the best place for such a method.
- Parameters:
set
- The set whose compliance is to be checked.- Returns:
- The earliest version of the SSSOM specification that defines all slots and values required by the set.
-
validate(MappingSet)
to validate an entire mapping set instead.