Class InMemoryRepository

java.lang.Object
net.aifusion.metamodel.InMemoryRepository
All Implemented Interfaces:
Repository

public class InMemoryRepository extends Object implements Repository
Simple in-memory cache for model objects. Supports a single namespace and no persistence.
Author:
Sharad Singhal
  • 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

      public InMemoryRepository(NameSpacePath path)
      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

      public boolean put(NamedElement element)
      Description copied from interface: Repository
      Put a named element into the repository
      Specified by:
      put in interface Repository
      Parameters:
      element - - element to be added
      Returns:
      - true if successfully added, false otherwise
    • get

      public NamedElement get(ObjectPath path)
      Description copied from interface: Repository
      Get a named element from the repository
      Specified by:
      get in interface Repository
      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

      public boolean contains(ObjectPath path)
      Description copied from interface: Repository
      Check if a named element exists in the repository
      Specified by:
      contains in interface Repository
      Parameters:
      path - - object path corresponding to the named element
      Returns:
      - true if the path exists in the repository, false otherwise
    • delete

      public boolean delete(ObjectPath path)
      Description copied from interface: Repository
      Delete a named element from the repository
      Specified by:
      delete in interface Repository
      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 interface Repository
    • getNameSpaces

      public List<NameSpacePath> 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 interface Repository
      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 interface Repository
      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 spaces
      elementNames - - 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 returned
      locateSubTypes - - 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

      public List<StructureValue> filter(ObjectPath path, CimFilter filter)
      Description copied from interface: Repository
      Find all structure value instances based on some filter criteria
      Specified by:
      filter in interface Repository
      Parameters:
      path - - object path to the structure to use
      filter - - filter to apply
      Returns:
      - list of structureValues that pass the given filter. Empty list if none available