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

  • All Implemented Interfaces:
    Accessor<T>
    Direct Known Subclasses:
    InMemoryAccessor

    public class AbstractAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
    extends Object
    implements Accessor<T>
    • Field Detail

      • collectionDriver

        protected final Collection<T extends step.core.accessors.AbstractIdentifiableObject> collectionDriver
    • Constructor Detail

      • AbstractAccessor

        public AbstractAccessor​(Collection<T> collectionDriver)
    • Method Detail

      • getCollectionDriver

        public Collection<T> getCollectionDriver()
      • 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​(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
      • findByCriteria

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

        public Stream<T> findManyByCriteria​(Map<String,​String> criteria)
        Description copied from interface: Accessor
        Find objects by criteria.
        Specified by:
        findManyByCriteria in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        criteria - the map of mandatory criteria of the object to be found
        Returns:
        an Iterator for the objects found
      • findByAttributes

        public T findByAttributes​(Map<String,​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 Spliterator<T> findManyByAttributes​(Map<String,​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​(Map<String,​String> attributes,
                                  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 Spliterator<T> findManyByAttributes​(Map<String,​String> attributes,
                                                   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 Iterator<T> getAll()
        Specified by:
        getAll in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
      • stream

        public Stream<T> stream()
        Specified by:
        stream in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Returns:
        a Stream with all objects
      • remove

        public void remove​(org.bson.types.ObjectId id)
        Description copied from interface: Accessor
        Remove an entity.
        Specified by:
        remove in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        id - id the entity
      • save

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

        public void save​(Iterable<T> entities)
        Description copied from interface: Accessor
        Save a list of entities.
        Specified by:
        save in interface Accessor<T extends step.core.accessors.AbstractIdentifiableObject>
        Parameters:
        entities - the list of entities to be saved
      • getRange

        public 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
      • createOrUpdateIndex

        protected void createOrUpdateIndex​(String field)
      • createOrUpdateCompoundIndex

        protected void createOrUpdateCompoundIndex​(String... fields)