Interface CanonicalValueSupport<T extends CanonicalValue<T>>

Type Parameters:
T - canonical value type
All Superinterfaces:
CanonicalValueValidator<T,T>, Immutable
All Known Implementing Classes:
AbstractCanonicalValueSupport, Decimal64.Support, Uint16.Support, Uint32.Support, Uint64.Support, Uint8.Support

@Beta @NonNullByDefault public interface CanonicalValueSupport<T extends CanonicalValue<T>> extends CanonicalValueValidator<T,T>
Support for a CanonicalValue subclasses. An implementation of this interface must be registered in the system and be available from each CanonicalValue object.

Note: never implement this interface directly, subclass AbstractCanonicalValueSupport instead.

This interface allows a CanonicalValue to be instantiated from a String. The implementation is expected to perform all checks implied by the corresponding YANG data model.

Author:
Robert Varga
  • Method Details

    • fromString

      Create a instance for a string representation. Implementations of this method are required to perform checks equivalent to the YANG data model restrictions attached to the corresponding YANG type. Non-canonical format strings must be accepted and result in objects equal to objects obtained from the corresponding canonical format.
      Parameters:
      str - String representation
      Returns:
      A CanonicalValue instance or CanonicalValueViolation if str does not conform
      Throws:
      NullPointerException - if str is null
    • fromCanonicalString

      default Either<T,CanonicalValueViolation> fromCanonicalString(String str)
      Create a instance for the canonical string representation. Implementations of this method may perform optimizations based on the assumption the string is canonical, but should still report errors when a mismatch is detected.
      Parameters:
      str - String representation
      Returns:
      A CanonicalValue instance or CanonicalValueViolation if str does not conform
      Throws:
      NullPointerException - if str is null
    • unsafe

      default <X extends CanonicalValue<X>> CanonicalValueSupport<X> unsafe()
      Unsafe cast to a factory type.
      Returns:
      This instance cast to specified type