Class AbstractCanonicalValueValidator<T extends DerivedString<T>,V extends T>
java.lang.Object
org.opendaylight.yangtools.yang.common.AbstractCanonicalValueValidator<T,V>
- Type Parameters:
T
- string representation classV
- validated string representation class
- All Implemented Interfaces:
Immutable
,CanonicalValueValidator<T,
V>
@Beta
@NonNullByDefault
public abstract class AbstractCanonicalValueValidator<T extends DerivedString<T>,V extends T>
extends Object
implements CanonicalValueValidator<T,V>
Abstract base class for implementing validators.
- Author:
- Robert Varga
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCanonicalValueValidator
(CanonicalValueSupport<T> representationSupport, Class<V> validatedClass) -
Method Summary
Modifier and TypeMethodDescriptionReturns the instantiated representation class.Return the class which captures the fact it was validated by this validator.protected Either<T,
CanonicalValueViolation> Validate aDerivedString
representation.protected abstract Either<T,
CanonicalValueViolation> Validate aDerivedString
representation.final Either<T,
CanonicalValueViolation> validateRepresentation
(T value) Validate aCanonicalValue
representation.final Either<T,
CanonicalValueViolation> validateRepresentation
(T value, String canonicalString) Validate aCanonicalValue
representation.
-
Constructor Details
-
AbstractCanonicalValueValidator
protected AbstractCanonicalValueValidator(CanonicalValueSupport<T> representationSupport, Class<V> validatedClass)
-
-
Method Details
-
getRepresentationClass
Description copied from interface:CanonicalValueValidator
Returns the instantiated representation class. The representation class is aCanonicalValue
which understands the semantics of modeled data and has some internal representation of it. AllCanonicalValue
s which share the same representation class are considered equal if their internal state would result in the same canonical string representation as defined by the YANG data model.- Specified by:
getRepresentationClass
in interfaceCanonicalValueValidator<T extends DerivedString<T>,
V extends T> - Returns:
- Representation
CanonicalValue
class.
-
getValidatedRepresentationClass
Description copied from interface:CanonicalValueValidator
Return the class which captures the fact it was validated by this validator.- Specified by:
getValidatedRepresentationClass
in interfaceCanonicalValueValidator<T extends DerivedString<T>,
V extends T> - Returns:
- Validated capture of the representation class.
-
validateRepresentation
Description copied from interface:CanonicalValueValidator
Validate aCanonicalValue
representation. Implementations should override this method if they can provide a validation algorithm which does not rely on canonical strings but works on representation state only.- Specified by:
validateRepresentation
in interfaceCanonicalValueValidator<T extends DerivedString<T>,
V extends T> - Parameters:
value
- Representation value- Returns:
- Validated representation or a
CanonicalValueViolation
-
validateRepresentation
public final Either<T,CanonicalValueViolation> validateRepresentation(T value, String canonicalString) Description copied from interface:CanonicalValueValidator
Validate aCanonicalValue
representation. Implementations can chose whether they operate on representation state or canonical string -- both are considered equivalent. Users should call this method if they have a representation readily available.- Specified by:
validateRepresentation
in interfaceCanonicalValueValidator<T extends DerivedString<T>,
V extends T> - Parameters:
value
- Representation valuecanonicalString
- Canonical string matching the representation value- Returns:
- Validated representation or a
CanonicalValueViolation
-
validate
Validate aDerivedString
representation. Subclasses should override this method if they can provide a validation algorithm which does not rely on canonical strings but works on representation state only.- Parameters:
value
- Representation value- Returns:
- Validated representation or CanonicalValueViolation
- Throws:
NullPointerException
- ifvalue
is null
-
validate
Validate aDerivedString
representation. Subclasses can chose whether they operate on representation state or canonical string -- both are considered equivalent.- Parameters:
value
- Representation valuecanonicalString
- Canonical string matching the representation value- Returns:
- Validated representation
- Throws:
NullPointerException
- ifvalue
orcanonicalString
is null.
-