Class ManifestNodeCache<T>
java.lang.Object
com.kosdev.kos.core.service.manifest.ManifestNodeCache<T>
Simple cache for node related data. This is commonly used by
IfaceAwareNodeService to populate per-node data for the
underlying service.
This is essentially a map of nodeId / data, where the data is
created by an instance of NodeDataFactory when there
is a cache miss. In the event of a cache miss, the nodeId will
be validated against the list of nodes defined in the current
manifest. If the nodeId isn't defined, no data will be added
to the cache. This effectively ensures that we only gather
cache data for nodes that are well defined by the currently
running manifest.
- Since:
- 9
- Version:
- 9
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface to create a new data object in the event of a cache miss in theManifestNodeCache. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new cache with the specified factory to allocate a new node when required. -
Method Summary
Modifier and TypeMethodDescriptionReturn the data for the specified nodeId.getNodes()Return the list of nodes from the cache.getOrCreate(NodeId nodeId) Return the data for the specified nodeId, creating a new data object using the associated factory if the nodeId isn't in the cache.
-
Constructor Details
-
ManifestNodeCache
Create a new cache with the specified factory to allocate a new node when required.- Parameters:
factory- factory to create new nodes- Since:
- 9
-
-
Method Details
-
get
Return the data for the specified nodeId.- Parameters:
nodeId- the nodeId to query- Returns:
- the associated node data or null
- Since:
- 9
-
getOrCreate
Return the data for the specified nodeId, creating a new data object using the associated factory if the nodeId isn't in the cache. Returns null if the specified nodeId isn't defined in the currently running manifest.- Parameters:
nodeId- the nodeId to query- Returns:
- the associated data or null
- Since:
- 9
-
getNodes
Return the list of nodes from the cache.
-