Class LayeredCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>

  • All Implemented Interfaces:
    Accessor<T>, CRUDAccessor<T>

    public class LayeredCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
    extends java.lang.Object
    implements CRUDAccessor<T>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAccessor​(CRUDAccessor<T> accessor)  
      T findByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
      Find an object by default attributes.
      T findByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes, java.lang.String attributesMapKey)
      Find an object by attributes.
      java.util.Spliterator<T> findManyByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
      Find objects by attributes.
      java.util.Spliterator<T> findManyByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes, java.lang.String attributesMapKey)
      Find objects by attributes.
      T get​(java.lang.String id)
      Get an object by id
      T get​(org.bson.types.ObjectId id)
      Get an object by id
      protected CRUDAccessor<T> getAccessorForPersistence()  
      java.util.Iterator<T> getAll()  
      java.util.List<T> getRange​(int skip, int limit)
      Get the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending order
      protected <V> V layeredLookup​(java.util.function.Function<CRUDAccessor<T>,​V> f)  
      protected <V> java.util.Spliterator<V> layeredMerge​(java.util.function.Function<CRUDAccessor<T>,​java.util.Spliterator<V>> f)  
      void pushAccessor​(CRUDAccessor<T> accessor)  
      void remove​(org.bson.types.ObjectId id)  
      void save​(java.util.Collection<? extends T> entities)
      Save a list of entities.
      T save​(T entity)
      Save an entity.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LayeredCRUDAccessor

        public LayeredCRUDAccessor()
      • LayeredCRUDAccessor

        public LayeredCRUDAccessor​(java.util.List<? extends CRUDAccessor<T>> accessors)
    • Method Detail

      • addAccessor

        public void addAccessor​(CRUDAccessor<T> accessor)
      • pushAccessor

        public void pushAccessor​(CRUDAccessor<T> accessor)
      • get

        public T get​(org.bson.types.ObjectId id)
        Description copied from interface: Accessor
        Get an object by id
        Specified by:
        get in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        id - the UID of the object
        Returns:
        the object
      • layeredLookup

        protected <V> V layeredLookup​(java.util.function.Function<CRUDAccessor<T>,​V> f)
      • get

        public T get​(java.lang.String id)
        Description copied from interface: Accessor
        Get an object by id
        Specified by:
        get in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        id - the UID of the object
        Returns:
        the object
      • findByAttributes

        public T findByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
        Description copied from interface: Accessor
        Find an object by default attributes. If multiple objects match these attributes, the first one will be returned
        Specified by:
        findByAttributes in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        attributes - the map of mandatory attributes of the object to be found
        Returns:
        the object
      • findManyByAttributes

        public java.util.Spliterator<T> findManyByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
        Description copied from interface: Accessor
        Find objects by attributes.
        Specified by:
        findManyByAttributes in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        attributes - the map of mandatory attributes of the object to be found
        Returns:
        an Iterator for the objects found
      • layeredMerge

        protected <V> java.util.Spliterator<V> layeredMerge​(java.util.function.Function<CRUDAccessor<T>,​java.util.Spliterator<V>> f)
      • getAll

        public java.util.Iterator<T> getAll()
        Specified by:
        getAll in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
      • findByAttributes

        public T findByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes,
                                  java.lang.String attributesMapKey)
        Description copied from interface: Accessor
        Find an object by attributes. If multiple objects match these attributes, the first one will be returned
        Specified by:
        findByAttributes in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        attributes - the map of mandatory attributes of the object to be found
        attributesMapKey - the string representing the name (or "key") of the attribute map
        Returns:
        the object
      • findManyByAttributes

        public java.util.Spliterator<T> findManyByAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes,
                                                             java.lang.String attributesMapKey)
        Description copied from interface: Accessor
        Find objects by attributes.
        Specified by:
        findManyByAttributes in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        attributes - the map of mandatory attributes of the object to be found
        attributesMapKey - the string representing the name (or "key") of the attribute map
        Returns:
        an Iterator for the objects found
      • getRange

        public java.util.List<T> getRange​(int skip,
                                          int limit)
        Description copied from interface: Accessor
        Get the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending order
        Specified by:
        getRange in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        skip - the start index (inclusive) of the range
        limit - the size of the range
        Returns:
        a List containing the objects of the specified range
      • remove

        public void remove​(org.bson.types.ObjectId id)
        Specified by:
        remove in interface CRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
      • save

        public T save​(T entity)
        Description copied from interface: CRUDAccessor
        Save an entity. If an entity with the same id exists, it will be updated otherwise inserted.
        Specified by:
        save in interface CRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        entity - the entity instance to be saved
        Returns:
        the saved entity
      • save

        public void save​(java.util.Collection<? extends T> entities)
        Description copied from interface: CRUDAccessor
        Save a list of entities.
        Specified by:
        save in interface CRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        entities - the list of entities to be saved
      • getAccessorForPersistence

        protected CRUDAccessor<T> getAccessorForPersistence()