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
,MutationBehaviour<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 ofCanonicalValueSupport
. This class should be used as superclass to all implementations ofCanonicalValueSupport
, as doing so provides a simpler base and enforces some aspects of the subclass.- Author:
- Robert Varga
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCanonicalValueSupport(Class<T> representationClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>
getRepresentationClass()
Returns the instantiated representation class.Class<T>
getValidatedRepresentationClass()
Return the class which captures the fact it was validated by this validator.Either<T,CanonicalValueViolation>
validateRepresentation(T value)
Validate aCanonicalValue
representation.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
-
-
-
-
Method Detail
-
getRepresentationClass
public final Class<T> 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
public final Class<T> 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
public final Either<T,CanonicalValueViolation> validateRepresentation(T value)
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
-
-