Class NamespaceBehaviour<K,V>
java.lang.Object
org.opendaylight.yangtools.concepts.AbstractIdentifiable<T,T>
org.opendaylight.yangtools.concepts.AbstractSimpleIdentifiable<ParserNamespace<K,V>>
org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour<K,V>
- Type Parameters:
K
- Key typeV
- Value type
- All Implemented Interfaces:
Identifiable<ParserNamespace<K,
V>>
- Direct Known Subclasses:
DerivedNamespaceBehaviour
public abstract class NamespaceBehaviour<K,V>
extends AbstractSimpleIdentifiable<ParserNamespace<K,V>>
Definition / implementation of specific Identifier Namespace behaviour. A namespace behaviour is built on top
of a tree of
NamespaceBehaviour.NamespaceStorageNode
which represents local context of one of types defined
n NamespaceBehaviour.StorageNodeType
.
For common behaviour models please use static factories global(ParserNamespace)
,
sourceLocal(ParserNamespace)
and treeScoped(ParserNamespace)
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
Interface implemented byNamespaceBehaviour.NamespaceStorageNode
s which support dynamic addition of child elements as they are requested.static interface
static enum
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addTo
(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value) Adds a key/value to corresponding namespace storage according to param class.protected final void
addToStorage
(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value) protected MoreObjects.ToStringHelper
protected static NamespaceBehaviour.NamespaceStorageNode
findClosestTowardsRoot
(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceBehaviour.StorageNodeType type) Returns all values of a keys of param class from model namespace storage.abstract V
getFrom
(NamespaceBehaviour.NamespaceStorageNode storage, K key) Returns a value from model namespace storage according to key param class.getFrom
(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceKeyCriterion<K> criterion) Returns the key/value mapping best matching specified criterion.protected final V
getFromLocalStorage
(NamespaceBehaviour.NamespaceStorageNode storage, K key) static <K,
V> @NonNull NamespaceBehaviour<K, V> global
(ParserNamespace<K, V> identifier) Creates a global namespace behaviour for supplied namespace type.static <K,
V> @NonNull NamespaceBehaviour<K, V> rootStatementLocal
(ParserNamespace<K, V> identifier) Creates a root-statement-local namespace behaviour for supplied namespace type.static <K,
V> @NonNull NamespaceBehaviour<K, V> sourceLocal
(ParserNamespace<K, V> identifier) Creates source-local namespace behaviour for supplied namespace type.static <K,
V> @NonNull NamespaceBehaviour<K, V> statementLocal
(ParserNamespace<K, V> identifier) static <K,
V> @NonNull NamespaceBehaviour<K, V> treeScoped
(ParserNamespace<K, V> identifier) Creates tree-scoped namespace behaviour for supplied namespace type.Methods inherited from class org.opendaylight.yangtools.concepts.AbstractIdentifiable
getIdentifier, toString
-
Constructor Details
-
NamespaceBehaviour
-
-
Method Details
-
global
Creates a global namespace behaviour for supplied namespace type. Global behaviour stores and loads all values from rootNamespaceBehaviour.NamespaceStorageNode
with type ofNamespaceBehaviour.StorageNodeType.GLOBAL
.- Type Parameters:
K
- type parameterV
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- global namespace behaviour for supplied namespace type.
-
sourceLocal
Creates source-local namespace behaviour for supplied namespace type. Source-local namespace behaviour stores and loads all values from closestNamespaceBehaviour.NamespaceStorageNode
ancestor with type ofNamespaceBehaviour.StorageNodeType.SOURCE_LOCAL_SPECIAL
.- Type Parameters:
K
- type parameterV
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- source-local namespace behaviour for supplied namespace type.
-
statementLocal
public static <K,V> @NonNull NamespaceBehaviour<K,V> statementLocal(ParserNamespace<K, V> identifier) -
rootStatementLocal
public static <K,V> @NonNull NamespaceBehaviour<K,V> rootStatementLocal(ParserNamespace<K, V> identifier) Creates a root-statement-local namespace behaviour for supplied namespace type. Root-statement-local namespace behaviour stores and loads all values from closestNamespaceBehaviour.NamespaceStorageNode
ancestor with type ofNamespaceBehaviour.StorageNodeType.ROOT_STATEMENT_LOCAL
.- Type Parameters:
K
- type parameterV
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- root-statement-local namespace behaviour for supplied namespace type.
-
treeScoped
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
- type parameterV
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- tree-scoped namespace behaviour for supplied namespace type.
-
getFrom
Returns a value from model namespace storage according to key param class.- Parameters:
storage
- namespace storagekey
- type parameter- Returns:
- value from model namespace storage according to key param class
-
getFrom
public final Optional<Map.Entry<K,V>> getFrom(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceKeyCriterion<K> criterion) Returns the key/value mapping best matching specified criterion.- Parameters:
storage
- namespace storagecriterion
- selection criterion- Returns:
- Selected mapping, if available.
-
getAllFrom
Returns all values of a keys of param class from model namespace storage.- Parameters:
storage
- namespace storage- Returns:
- all values of keys of param class from model namespace storage
-
addTo
Adds a key/value to corresponding namespace storage according to param class.- Parameters:
storage
- namespace storagekey
- type parametervalue
- type parameter
-
getFromLocalStorage
-
getAllFromLocalStorage
-
addToStorage
-
findClosestTowardsRoot
protected static NamespaceBehaviour.NamespaceStorageNode findClosestTowardsRoot(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceBehaviour.StorageNodeType type) -
addToStringAttributes
- Overrides:
addToStringAttributes
in classAbstractIdentifiable<ParserNamespace<K,
V>, ParserNamespace<K, V>>
-