Package step.core.accessors
Class LayeredCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
- java.lang.Object
-
- step.core.accessors.LayeredCRUDAccessor<T>
-
- All Implemented Interfaces:
Accessor<T>,CRUDAccessor<T>
public class LayeredCRUDAccessor<T extends step.core.accessors.AbstractIdentifiableObject> extends java.lang.Object implements CRUDAccessor<T>
-
-
Constructor Summary
Constructors Constructor Description LayeredCRUDAccessor()LayeredCRUDAccessor(java.util.List<? extends CRUDAccessor<T>> accessors)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAccessor(CRUDAccessor<T> accessor)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 idprotected 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 orderprotected <V> VlayeredLookup(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)voidpushAccessor(CRUDAccessor<T> accessor)voidremove(org.bson.types.ObjectId id)voidsave(java.util.Collection<? extends T> entities)Save a list of entities.Tsave(T entity)Save an entity.
-
-
-
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:AccessorGet an object by id
-
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: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
-
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()
-
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
-
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
-
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
-
getAccessorForPersistence
protected CRUDAccessor<T> getAccessorForPersistence()
-
-