Class NamespaceBehaviour<K,V,N extends IdentifierNamespace<K,V>>
- java.lang.Object
-
- org.opendaylight.yangtools.concepts.AbstractIdentifiable<Class<N>>
-
- org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour<K,V,N>
-
- Type Parameters:
K
- Key typeV
- Value typeN
- Namespace Type
- All Implemented Interfaces:
Identifiable<Class<N>>
- Direct Known Subclasses:
ChildSchemaNodeNamespace
,DerivedNamespaceBehaviour
public abstract class NamespaceBehaviour<K,V,N extends IdentifierNamespace<K,V>> extends AbstractIdentifiable<Class<N>>
Definition / implementation of specific Identifier Namespace behaviour. A namespace behaviour is built on top of a tree ofNamespaceBehaviour.NamespaceStorageNode
which represents local context of one of types defined nNamespaceBehaviour.StorageNodeType
.For common behaviour models please use static factories
global(Class)
,sourceLocal(Class)
andtreeScoped(Class)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NamespaceBehaviour.NamespaceStorageNode
static interface
NamespaceBehaviour.Registry
static class
NamespaceBehaviour.StorageNodeType
-
Constructor Summary
Constructors Modifier Constructor Description protected
NamespaceBehaviour(Class<N> identifier)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addTo(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value)
Adds a key/value to corresponding namespace storage according to param class.protected void
addToStorage(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value)
protected MoreObjects.ToStringHelper
addToStringAttributes(MoreObjects.ToStringHelper helper)
protected static NamespaceBehaviour.NamespaceStorageNode
findClosestTowardsRoot(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceBehaviour.StorageNodeType type)
abstract Map<K,V>
getAllFrom(NamespaceBehaviour.NamespaceStorageNode storage)
Returns all values of a keys of param class from model namespace storage.protected Map<K,V>
getAllFromLocalStorage(NamespaceBehaviour.NamespaceStorageNode storage)
abstract V
getFrom(NamespaceBehaviour.NamespaceStorageNode storage, K key)
Returns a value from model namespace storage according to key param class.Optional<Map.Entry<K,V>>
getFrom(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceKeyCriterion<K> criterion)
Returns the key/value mapping best matching specified criterion.protected V
getFromLocalStorage(NamespaceBehaviour.NamespaceStorageNode storage, K key)
static <K,V,N extends IdentifierNamespace<K,V>>
@NonNull NamespaceBehaviour<K,V,N>global(Class<N> identifier)
Creates a global namespace behaviour for supplied namespace type.static <K,V,N extends IdentifierNamespace<K,V>>
@NonNull NamespaceBehaviour<K,V,N>rootStatementLocal(Class<N> identifier)
Creates a root-statement-local namespace behaviour for supplied namespace type.static <K,V,N extends IdentifierNamespace<K,V>>
@NonNull NamespaceBehaviour<K,V,N>sourceLocal(Class<N> identifier)
Creates source-local namespace behaviour for supplied namespace type.static <K,V,N extends IdentifierNamespace<K,V>>
@NonNull NamespaceBehaviour<K,V,N>statementLocal(Class<N> identifier)
static <K,V,N extends IdentifierNamespace<K,V>>
@NonNull NamespaceBehaviour<K,V,N>treeScoped(Class<N> identifier)
Creates tree-scoped namespace behaviour for supplied namespace type.-
Methods inherited from class org.opendaylight.yangtools.concepts.AbstractIdentifiable
getIdentifier, toString
-
-
-
-
Method Detail
-
global
public static <K,V,N extends IdentifierNamespace<K,V>> @NonNull NamespaceBehaviour<K,V,N> global(Class<N> identifier)
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 parameterN
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- global namespace behaviour for supplied namespace type.
-
sourceLocal
public static <K,V,N extends IdentifierNamespace<K,V>> @NonNull NamespaceBehaviour<K,V,N> sourceLocal(Class<N> identifier)
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 parameterN
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- source-local namespace behaviour for supplied namespace type.
-
statementLocal
public static <K,V,N extends IdentifierNamespace<K,V>> @NonNull NamespaceBehaviour<K,V,N> statementLocal(Class<N> identifier)
-
rootStatementLocal
public static <K,V,N extends IdentifierNamespace<K,V>> @NonNull NamespaceBehaviour<K,V,N> rootStatementLocal(Class<N> 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 parameterN
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- root-statement-local namespace behaviour for supplied namespace type.
-
treeScoped
public static <K,V,N extends IdentifierNamespace<K,V>> @NonNull NamespaceBehaviour<K,V,N> treeScoped(Class<N> identifier)
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 parameterN
- type parameter- Parameters:
identifier
- Namespace identifier.- Returns:
- tree-scoped namespace behaviour for supplied namespace type.
-
getFrom
public abstract V getFrom(NamespaceBehaviour.NamespaceStorageNode storage, K key)
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
public abstract Map<K,V> getAllFrom(NamespaceBehaviour.NamespaceStorageNode storage)
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
public abstract void addTo(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value)
Adds a key/value to corresponding namespace storage according to param class.- Parameters:
storage
- namespace storagekey
- type parametervalue
- type parameter
-
getFromLocalStorage
protected final V getFromLocalStorage(NamespaceBehaviour.NamespaceStorageNode storage, K key)
-
getAllFromLocalStorage
protected final Map<K,V> getAllFromLocalStorage(NamespaceBehaviour.NamespaceStorageNode storage)
-
addToStorage
protected final void addToStorage(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value)
-
findClosestTowardsRoot
protected static NamespaceBehaviour.NamespaceStorageNode findClosestTowardsRoot(NamespaceBehaviour.NamespaceStorageNode storage, NamespaceBehaviour.StorageNodeType type)
-
addToStringAttributes
protected MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper helper)
- Overrides:
addToStringAttributes
in classAbstractIdentifiable<Class<N extends IdentifierNamespace<K,V>>>
-
-