Class DynamicRepository


  • public class DynamicRepository
    extends Object

    Repository for saving a dynamic object tree

    Since:
    1.0
    Author:
    Christoph Praschl
    • Method Detail

      • save

        public <T> T save​(T node)
        Saves dynamically typed object tree
        Type Parameters:
        T - Type of node
        Parameters:
        node - root node to be saved
        Returns:
        node
      • load

        public <T> T load​(Long id,
                          Class<T> clazz)
        Dynamically loads the object tree with the node of the given id as root
        Type Parameters:
        T - type of the root node
        Parameters:
        id - id of the root node
        clazz - type of the root node
        Returns:
        The root node with loaded sub nodes
      • load

        public <T> T load​(Long id,
                          Class<T> clazz,
                          Class<?>... classes)
        Dynamically loads the object tree with the node of the given id as root
        Type Parameters:
        T - type of the root node
        Parameters:
        id - id of the root node
        clazz - type of the root node
        classes - classes of nodes which should not be loaded (if empty or null everything will be loaded)
        Returns:
        The root node with loaded sub nodes
      • load

        public <T> T load​(Long id,
                          Class<T> clazz,
                          List<Class<?>> classes)
        Dynamically loads the object tree with the node of the given id as root
        Type Parameters:
        T - type of the root node
        Parameters:
        id - id of the root node
        clazz - type of the root node
        classes - classes of nodes which should not be loaded (if empty or null everything will be loaded)
        Returns:
        The root node with loaded sub nodes
      • load

        public <T> T load​(Long id,
                          Class<T> clazz,
                          List<Class<?>> classes,
                          boolean classesForInclude)
        Dynamically loads the object tree with the node of the given id as root
        Type Parameters:
        T - type of the root node
        Parameters:
        id - id of the root node
        clazz - type of the root node
        classes - classes of nodes which should (not) be loaded (if empty or null everything will be loaded or nothing will be loaded)
        classesForInclude - if true classes parameter will be used as include list; otherwise as an exclude list
        Returns:
        The root node with loaded sub nodes
      • load

        public <T> T load​(Long id,
                          Class<T> clazz,
                          List<Class<?>> classes,
                          boolean classesForInclude,
                          Map<Class<?>,​Class<?>> loadMapping)
        Dynamically loads the object tree with the node of the given id as root Using the loadMapping parameter this method also allows to load elements with a given dynamic type.
        Type Parameters:
        T - type of the root node
        Parameters:
        id - id of the root node
        clazz - type of the root node
        classes - classes of nodes which should (not) be loaded (if empty or null everything will be loaded or nothing will be loaded); behaviour depends on classesForInclude parameter
        classesForInclude - if true the classes parameter will be used as include list; otherwise as an exclude list
        loadMapping - Map associating a base class which should be interpreted as another class. This means: Load class A with the repository of class B
        Returns:
        The root node with loaded sub nodes
      • getLabels

        public List<String> getLabels​(long id)