Package net.aifusion.metamodel
Class InMemoryRepository
java.lang.Object
net.aifusion.metamodel.InMemoryRepository
- All Implemented Interfaces:
Repository
Simple in-memory cache for model objects. Supports a single namespace and no persistence.
- Author:
- Sharad Singhal
-
Constructor Summary
ConstructorDescriptionCreate an in-memory CIM repository using the default name space.Create an in-memory CIM repository using the given name space. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(ObjectPath path) Check if a named element exists in the repositoryboolean
delete
(ObjectPath path) Delete a named element from the repositoryfilter
(ObjectPath path, CimFilter filter) Find all structure value instances based on some filter criteriaget
(ObjectPath path) Get a named element from the repositorygetElements
(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes) Get elements from this repository.Get a list of all name spaces known to this repository.boolean
put
(NamedElement element) Put a named element into the repositoryvoid
shutdown()
Shut down the repository.
-
Constructor Details
-
InMemoryRepository
public InMemoryRepository()Create an in-memory CIM repository using the default name space. This repository supports only the default namespace, and no persistence. Standard qualifier types are built-in, and do not have to be inserted in the repository- See Also:
-
InMemoryRepository
Create an in-memory CIM repository using the given name space. No persistence is supported. Standard qualifier types are built-in, and do not have to be inserted in the repository- Parameters:
path
- - name space to be used in the repository. Must not be null.- See Also:
-
-
Method Details
-
put
Description copied from interface:Repository
Put a named element into the repository- Specified by:
put
in interfaceRepository
- Parameters:
element
- - element to be added- Returns:
- - true if successfully added, false otherwise
-
get
Description copied from interface:Repository
Get a named element from the repository- Specified by:
get
in interfaceRepository
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - Named Element corresponding to the element. Null returned if no such element exists in the repository
-
contains
Description copied from interface:Repository
Check if a named element exists in the repository- Specified by:
contains
in interfaceRepository
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - true if the path exists in the repository, false otherwise
-
delete
Description copied from interface:Repository
Delete a named element from the repository- Specified by:
delete
in interfaceRepository
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - true if deletion succeeded, false otherwise
-
shutdown
public void shutdown()Description copied from interface:Repository
Shut down the repository. This method MUST be called before exiting to cleanly finish all pending tasks and release resources in the repository- Specified by:
shutdown
in interfaceRepository
-
getNameSpaces
Description copied from interface:Repository
Get a list of all name spaces known to this repository. Note that because implementations can add or remove name spaces as elements are added or deleted, this list may not be complete, and depends on the repository implementation- Specified by:
getNameSpaces
in interfaceRepository
- Returns:
- - list of name spaces
-
getElements
public List<NamedElement> getElements(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes) Description copied from interface:Repository
Get elements from this repository. Depending on the size of the repository, this method can be very expensive in time and/or memory- Specified by:
getElements
in interfaceRepository
- Parameters:
elementTypes
- - Optional comma separated list of element types to retrieve. Must be a NamedElement type (QualifierType, Enumeration, Interface, Structure, Class, StructureValue or Instance). A null will retrieve all types. Note that standard qualifier types are "built in" and are not returned by this method.localNameSpaces
- - Optional comma separated list of local name spaces to search. A null will retrieve elements from all name spaceselementNames
- - Optional comma-separated list of element names to retrieve. A null will retrieve all elements of the given type. For instances, all instances corresponding to the class name are returnedlocateSubTypes
- - if true, locate all subtypes of the given element types (e.g., all subclasses of the requested class).- Returns:
- - list of elements that match the given criteria. An empty list is returned if no matching elements are found
- See Also:
-
filter
Description copied from interface:Repository
Find all structure value instances based on some filter criteria- Specified by:
filter
in interfaceRepository
- Parameters:
path
- - object path to the structure to usefilter
- - filter to apply- Returns:
- - list of structureValues that pass the given filter. Empty list if none available
-