Package step.core.accessors
Class AbstractAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
- java.lang.Object
-
- step.core.accessors.AbstractAccessor<T>
-
- All Implemented Interfaces:
Accessor<T>
- Direct Known Subclasses:
InMemoryAccessor
public class AbstractAccessor<T extends step.core.accessors.AbstractIdentifiableObject> extends Object implements Accessor<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected Collection<T>collectionDriver
-
Constructor Summary
Constructors Constructor Description AbstractAccessor(Collection<T> collectionDriver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateOrUpdateCompoundIndex(String... fields)protected voidcreateOrUpdateIndex(String field)TfindByAttributes(Map<String,String> attributes)Find an object by default attributes.TfindByAttributes(Map<String,String> attributes, String attributesMapKey)Find an object by attributes.TfindByCriteria(Map<String,String> criteria)Find an object by criteria.Spliterator<T>findManyByAttributes(Map<String,String> attributes)Find objects by attributes.Spliterator<T>findManyByAttributes(Map<String,String> attributes, String attributesMapKey)Find objects by attributes.Stream<T>findManyByCriteria(Map<String,String> criteria)Find objects by criteria.Tget(String id)Get an object by idTget(org.bson.types.ObjectId id)Get an object by idIterator<T>getAll()Collection<T>getCollectionDriver()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 ordervoidremove(org.bson.types.ObjectId id)Remove an entity.voidsave(Iterable<T> entities)Save a list of entities.Tsave(T entity)Save an entity.Stream<T>stream()
-
-
-
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:AccessorGet an object by id
-
findByCriteria
public T findByCriteria(Map<String,String> criteria)
Description copied from interface:AccessorFind an object by criteria. If multiple objects match these criteria, the first one will be returned- Specified by:
findByCriteriain interfaceAccessor<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:AccessorFind objects by criteria.- Specified by:
findManyByCriteriain interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
criteria- the map of mandatory criteria of the object to be found- Returns:
- an
Iteratorfor the objects found
-
findByAttributes
public T findByAttributes(Map<String,String> attributes)
Description copied from interface:AccessorFind an object by default attributes. If multiple objects match these attributes, the first one will be returned- Specified by:
findByAttributesin interfaceAccessor<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:AccessorFind objects by attributes.- Specified by:
findManyByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be found- Returns:
- an
Iteratorfor the objects found
-
findByAttributes
public T findByAttributes(Map<String,String> attributes, String attributesMapKey)
Description copied from interface:AccessorFind an object by attributes. If multiple objects match these attributes, the first one will be returned- Specified by:
findByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be foundattributesMapKey- 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:AccessorFind objects by attributes.- Specified by:
findManyByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be foundattributesMapKey- the string representing the name (or "key") of the attribute map- Returns:
- an
Iteratorfor the objects found
-
remove
public void remove(org.bson.types.ObjectId id)
Description copied from interface:AccessorRemove an entity.
-
save
public T save(T entity)
Description copied from interface:AccessorSave an entity. If an entity with the same id exists, it will be updated otherwise inserted.
-
save
public void save(Iterable<T> entities)
Description copied from interface:AccessorSave a list of entities.
-
getRange
public List<T> getRange(int skip, int limit)
Description copied from interface:AccessorGet the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending order
-
createOrUpdateIndex
protected void createOrUpdateIndex(String field)
-
createOrUpdateCompoundIndex
protected void createOrUpdateCompoundIndex(String... fields)
-
-