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
ConstructorsModifierConstructorDescriptionprotectedAbstractCanonicalValueValidator(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 aDerivedStringrepresentation.protected abstract Either<T,CanonicalValueViolation> Validate aDerivedStringrepresentation.final Either<T,CanonicalValueViolation> validateRepresentation(T value) Validate aCanonicalValuerepresentation.final Either<T,CanonicalValueViolation> validateRepresentation(T value, String canonicalString) Validate aCanonicalValuerepresentation.
-
Constructor Details
-
AbstractCanonicalValueValidator
protected AbstractCanonicalValueValidator(CanonicalValueSupport<T> representationSupport, Class<V> validatedClass)
-
-
Method Details
-
getRepresentationClass
Description copied from interface:CanonicalValueValidatorReturns the instantiated representation class. The representation class is aCanonicalValuewhich understands the semantics of modeled data and has some internal representation of it. AllCanonicalValues 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:
getRepresentationClassin interfaceCanonicalValueValidator<T extends DerivedString<T>,V extends T> - Returns:
- Representation
CanonicalValueclass.
-
getValidatedRepresentationClass
Description copied from interface:CanonicalValueValidatorReturn the class which captures the fact it was validated by this validator.- Specified by:
getValidatedRepresentationClassin interfaceCanonicalValueValidator<T extends DerivedString<T>,V extends T> - Returns:
- Validated capture of the representation class.
-
validateRepresentation
Description copied from interface:CanonicalValueValidatorValidate aCanonicalValuerepresentation. 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:
validateRepresentationin 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:CanonicalValueValidatorValidate aCanonicalValuerepresentation. 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:
validateRepresentationin 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 aDerivedStringrepresentation. 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- ifvalueis null
-
validate
Validate aDerivedStringrepresentation. 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- ifvalueorcanonicalStringis null.
-