Class AbstractCanonicalValueSupport<T extends CanonicalValue<T>>
java.lang.Object
org.opendaylight.yangtools.yang.common.AbstractCanonicalValueSupport<T>
- Type Parameters:
T
- canonical value type
- All Implemented Interfaces:
Immutable
,CanonicalValueSupport<T>
,CanonicalValueValidator<T,
T>
- Direct Known Subclasses:
Decimal64.Support
,Uint16.Support
,Uint32.Support
,Uint64.Support
,Uint8.Support
@Beta
@NonNullByDefault
public abstract class AbstractCanonicalValueSupport<T extends CanonicalValue<T>>
extends Object
implements CanonicalValueSupport<T>
Base implementation of
CanonicalValueSupport
. This class should be used as superclass to all implementations
of CanonicalValueSupport
, as doing so provides a simpler base and enforces some aspects of the subclass.- Author:
- Robert Varga
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCanonicalValueSupport
(Class<T> representationClass) -
Method Summary
Modifier and TypeMethodDescriptionReturns the instantiated representation class.Return the class which captures the fact it was validated by this validator.final Either<T,
CanonicalValueViolation> validateRepresentation
(T value) Validate aCanonicalValue
representation.final Either<T,
CanonicalValueViolation> validateRepresentation
(T value, String canonicalString) Validate aCanonicalValue
representation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opendaylight.yangtools.yang.common.CanonicalValueSupport
fromCanonicalString, fromString, unsafe
-
Constructor Details
-
AbstractCanonicalValueSupport
-
-
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 CanonicalValue<T>,
T extends CanonicalValue<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 CanonicalValue<T>,
T extends CanonicalValue<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 CanonicalValue<T>,
T extends CanonicalValue<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 CanonicalValue<T>,
T extends CanonicalValue<T>> - Parameters:
value
- Representation valuecanonicalString
- Canonical string matching the representation value- Returns:
- Validated representation or a
CanonicalValueViolation
-