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

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<org.bson.types.ObjectId,​T> map  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
      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 java.lang.RuntimeException notImplemented()  
      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
    • Field Detail

      • map

        protected java.util.Map<org.bson.types.ObjectId,​T extends step.core.accessors.AbstractIdentifiableObject> map
    • Constructor Detail

      • InMemoryCRUDAccessor

        public InMemoryCRUDAccessor()
    • Method Detail

      • 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
      • 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
      • 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
      • getAll

        public java.util.Iterator<T> getAll()
        Specified by:
        getAll in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
      • 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
      • 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
      • notImplemented

        protected java.lang.RuntimeException notImplemented()