Package step.core.accessors
Class InMemoryCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
- java.lang.Object
-
- step.core.accessors.InMemoryCRUDAccessor<T>
-
- All Implemented Interfaces:
Accessor<T>,CRUDAccessor<T>
- Direct Known Subclasses:
InMemoryResourceAccessor,InMemoryResourceRevisionAccessor
public class InMemoryCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject> extends java.lang.Object implements CRUDAccessor<T>
-
-
Constructor Summary
Constructors Constructor Description InMemoryCRUDAccessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TfindByAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)Find an object by default attributes.TfindByAttributes(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.Tget(java.lang.String id)Get an object by idTget(org.bson.types.ObjectId id)Get an object by idjava.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 orderprotected java.lang.RuntimeExceptionnotImplemented()voidremove(org.bson.types.ObjectId id)voidsave(java.util.Collection<? extends T> entities)Save a list of entities.Tsave(T entity)Save an entity.
-
-
-
Field Detail
-
map
protected java.util.Map<org.bson.types.ObjectId,T extends step.core.accessors.AbstractIdentifiableObject> map
-
-
Method Detail
-
get
public T get(org.bson.types.ObjectId id)
Description copied from interface:AccessorGet an object by id
-
get
public T get(java.lang.String id)
Description copied from interface:AccessorGet an object by id
-
findByAttributes
public T findByAttributes(java.util.Map<java.lang.String,java.lang.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 java.util.Spliterator<T> findManyByAttributes(java.util.Map<java.lang.String,java.lang.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(java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.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 java.util.Spliterator<T> findManyByAttributes(java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.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
-
getAll
public java.util.Iterator<T> getAll()
-
remove
public void remove(org.bson.types.ObjectId id)
- Specified by:
removein interfaceCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
-
save
public T save(T entity)
Description copied from interface:CRUDAccessorSave an entity. If an entity with the same id exists, it will be updated otherwise inserted.- Specified by:
savein interfaceCRUDAccessor<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:CRUDAccessorSave a list of entities.- Specified by:
savein interfaceCRUDAccessor<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:AccessorGet the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending order
-
notImplemented
protected java.lang.RuntimeException notImplemented()
-
-