Class NamespaceBehaviour<K,V>

java.lang.Object
org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour<K,V>
Type Parameters:
K - Key type
V - Value type

public abstract class NamespaceBehaviour<K,V> extends Object
Definition / implementation of specific Identifier Namespace behaviour. A namespace behaviour is built on top of a tree of NamespaceStorage which represents local context of one of types defined in NamespaceStorage.StorageType.

For common behaviour models please use static factories global(ParserNamespace), sourceLocal(ParserNamespace) and treeScoped(ParserNamespace).

  • Constructor Details

  • Method Details

    • namespace

      public final @NonNull ParserNamespace<K,V> namespace()
    • global

      public static <K, V> @NonNull NamespaceBehaviour<K,V> global(ParserNamespace<K,V> namespace)
      Creates a global namespace behaviour for supplied namespace type. Global behaviour stores and loads all values from root NamespaceStorage with type of NamespaceStorage.StorageType.GLOBAL.
      Type Parameters:
      K - Namespace key type
      V - Namespace value type
      Parameters:
      namespace - Namespace identifier
      Returns:
      global namespace behaviour for supplied namespace type.
    • sourceLocal

      public static <K, V> @NonNull NamespaceBehaviour<K,V> sourceLocal(ParserNamespace<K,V> namespace)
      Creates source-local namespace behaviour for supplied namespace type. Source-local namespace behaviour stores and loads all values from closest NamespaceStorage ancestor with type of NamespaceStorage.StorageType.SOURCE_LOCAL_SPECIAL.
      Type Parameters:
      K - Namespace key type
      V - Namespace value type
      Parameters:
      namespace - Namespace identifier
      Returns:
      source-local namespace behaviour for supplied namespace type.
    • statementLocal

      public static <K, V> @NonNull NamespaceBehaviour<K,V> statementLocal(ParserNamespace<K,V> namespace)
    • rootStatementLocal

      public static <K, V> @NonNull NamespaceBehaviour<K,V> rootStatementLocal(ParserNamespace<K,V> namespace)
      Creates a root-statement-local namespace behaviour for supplied namespace type. Root-statement-local namespace behaviour stores and loads all values from closest NamespaceStorage ancestor with type of NamespaceStorage.StorageType.ROOT_STATEMENT_LOCAL.
      Type Parameters:
      K - Namespace key type
      V - Namespace value type
      Parameters:
      namespace - Namespace identifier
      Returns:
      root-statement-local namespace behaviour for supplied namespace type.
    • treeScoped

      public static <K, V> @NonNull NamespaceBehaviour<K,V> treeScoped(ParserNamespace<K,V> namespace)
      Creates tree-scoped namespace behaviour for supplied namespace type. Tree-scoped namespace behaviour searches for value in all storage nodes up to the root and stores values in supplied node.
      Type Parameters:
      K - Namespace key type
      V - Namespace value type
      Parameters:
      namespace - Namespace identifier
      Returns:
      tree-scoped namespace behaviour for supplied namespace type.
    • getFrom

      public abstract V getFrom(NamespaceStorage.GlobalStorage global, NamespaceStorage storage, K key)
      Returns a value from model namespace storage according to key param class.
      Parameters:
      global - global namespace storage
      storage - namespace storage
      key - type parameter
      Returns:
      value from model namespace storage according to key param class
    • getFrom

      public final @Nullable Map.Entry<K,V> getFrom(NamespaceStorage.GlobalStorage global, NamespaceStorage storage, NamespaceKeyCriterion<K> criterion)
      Returns the key/value mapping best matching specified criterion.
      Parameters:
      global - global namespace storage
      storage - namespace storage
      criterion - selection criterion
      Returns:
      Selected mapping, if available.
    • getAllFrom

      public abstract Map<K,V> getAllFrom(NamespaceStorage.GlobalStorage global, NamespaceStorage storage)
      Returns all values of a keys of param class from model namespace storage.
      Parameters:
      global - global namespace storage
      storage - namespace storage
      Returns:
      all values of keys of param class from model namespace storage
    • addTo

      public abstract void addTo(NamespaceStorage.GlobalStorage global, NamespaceStorage storage, K key, V value)
      Adds a key/value to corresponding namespace storage according to param class.
      Parameters:
      global - global namespace storage
      storage - namespace storage
      key - type parameter
      value - type parameter
    • getFromLocalStorage

      protected final V getFromLocalStorage(NamespaceStorage storage, K key)
    • getAllFromLocalStorage

      protected final Map<K,V> getAllFromLocalStorage(NamespaceStorage storage)
    • addToStorage

      protected final void addToStorage(NamespaceStorage storage, K key, V value)
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • addToStringAttributes

      protected MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper)