public class KeyValueTemplate extends Object implements KeyValueOperations, ApplicationEventPublisherAware
KeyValueOperations.| Constructor and Description |
|---|
KeyValueTemplate(KeyValueAdapter adapter)
|
KeyValueTemplate(KeyValueAdapter adapter,
MappingContext<? extends KeyValuePersistentEntity<?,?>,? extends KeyValuePersistentProperty<?>> mappingContext)
|
KeyValueTemplate(KeyValueAdapter adapter,
MappingContext<? extends KeyValuePersistentEntity<?,?>,? extends KeyValuePersistentProperty<?>> mappingContext,
IdentifierGenerator identifierGenerator)
|
| Modifier and Type | Method and Description |
|---|---|
long |
count(Class<?> type)
Total number of elements with given type available.
|
long |
count(KeyValueQuery<?> query,
Class<?> type)
Total number of elements matching given query.
|
void |
delete(Class<?> type)
Remove all elements of type.
|
<T> T |
delete(Object id,
Class<T> type)
Delete item of type with given id.
|
<T> T |
delete(T objectToDelete) |
void |
destroy() |
<T> T |
execute(KeyValueCallback<T> action)
Execute operation against underlying store.
|
protected <T> T |
executeRequired(KeyValueCallback<T> action)
Execute
KeyValueCallback and require a non-null return value. |
<T> Iterable<T> |
find(KeyValueQuery<?> query,
Class<T> type)
Get all elements matching the given query.
|
<T> Iterable<T> |
findAll(Class<T> type)
Get all elements of given type.
|
<T> Iterable<T> |
findAll(Sort sort,
Class<T> type)
Get all elements ordered by sort.
|
<T> Optional<T> |
findById(Object id,
Class<T> type)
Get element of given type with given id.
|
<T> Iterable<T> |
findInRange(long offset,
int rows,
Class<T> type)
Get all elements in given range.
|
<T> Iterable<T> |
findInRange(long offset,
int rows,
Sort sort,
Class<T> type)
Get all elements in given range ordered by sort.
|
MappingContext<?,?> |
getMappingContext() |
<T> T |
insert(Object id,
T objectToInsert)
Add object with given id.
|
<T> T |
insert(T objectToInsert)
Add given object.
|
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setEventTypesToPublish(Set<Class<? extends KeyValueEvent>> eventTypesToPublish)
Define the event types to publish via
ApplicationEventPublisher. |
void |
setExceptionTranslator(PersistenceExceptionTranslator exceptionTranslator)
Set the
PersistenceExceptionTranslator used for converting RuntimeException. |
<T> T |
update(Object id,
T objectToUpdate) |
<T> T |
update(T objectToUpdate) |
public KeyValueTemplate(KeyValueAdapter adapter)
adapter - must not be null.public KeyValueTemplate(KeyValueAdapter adapter, MappingContext<? extends KeyValuePersistentEntity<?,?>,? extends KeyValuePersistentProperty<?>> mappingContext)
adapter - must not be null.mappingContext - must not be null.public KeyValueTemplate(KeyValueAdapter adapter, MappingContext<? extends KeyValuePersistentEntity<?,?>,? extends KeyValuePersistentProperty<?>> mappingContext, IdentifierGenerator identifierGenerator)
adapter - must not be null.mappingContext - must not be null.identifierGenerator - must not be null.public void setExceptionTranslator(PersistenceExceptionTranslator exceptionTranslator)
PersistenceExceptionTranslator used for converting RuntimeException.exceptionTranslator - must not be null.public void setEventTypesToPublish(Set<Class<? extends KeyValueEvent>> eventTypesToPublish)
ApplicationEventPublisher.eventTypesToPublish - use null or Collections.emptySet() to stop publishing.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface ApplicationEventPublisherAwarepublic <T> T insert(T objectToInsert)
KeyValueOperationsinsert in interface KeyValueOperationspublic <T> T insert(Object id, T objectToInsert)
KeyValueOperationsinsert in interface KeyValueOperationsid - must not be null.objectToInsert - must not be null.public <T> T update(T objectToUpdate)
update in interface KeyValueOperationsobjectToUpdate - must not be null.public <T> T update(Object id, T objectToUpdate)
update in interface KeyValueOperationsid - must not be null.objectToUpdate - must not be null.public <T> Iterable<T> findAll(Class<T> type)
KeyValueOperationsKeySpace if present and therefore returns all elements that can be
assigned to requested type.findAll in interface KeyValueOperationstype - must not be null.public <T> Optional<T> findById(Object id, Class<T> type)
KeyValueOperationsKeySpace if present and therefore returns all elements
that can be assigned to requested type.findById in interface KeyValueOperationsid - must not be null.type - must not be null.Optional.empty() if not found.public void delete(Class<?> type)
KeyValueOperationsKeySpace if present and therefore removes all elements that can be
assigned to requested type.delete in interface KeyValueOperationstype - must not be null.public <T> T delete(T objectToDelete)
delete in interface KeyValueOperationsobjectToDelete - must not be null.public <T> T delete(Object id, Class<T> type)
KeyValueOperationsdelete in interface KeyValueOperationsid - must not be null.type - must not be null.public long count(Class<?> type)
KeyValueOperationsKeySpace if present and therefore counts all
elements that can be assigned to requested type.count in interface KeyValueOperationstype - must not be null.@Nullable public <T> T execute(KeyValueCallback<T> action)
KeyValueOperationsexecute in interface KeyValueOperationsaction - must not be null.protected <T> T executeRequired(KeyValueCallback<T> action)
KeyValueCallback and require a non-null return value.T - action - public <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type)
KeyValueOperationsKeySpace if present and therefore returns all elements that can be assigned to requested type..find in interface KeyValueOperationsquery - must not be null.type - must not be null.public <T> Iterable<T> findAll(Sort sort, Class<T> type)
KeyValueOperationsKeySpace if present and therefore returns all elements that can
be assigned to requested type.findAll in interface KeyValueOperationssort - must not be null.type - must not be null.public <T> Iterable<T> findInRange(long offset, int rows, Class<T> type)
KeyValueOperationsKeySpace if present and therefore returns all elements that can
be assigned to requested type.findInRange in interface KeyValueOperationstype - must not be null.public <T> Iterable<T> findInRange(long offset, int rows, Sort sort, Class<T> type)
KeyValueOperationsKeySpace if present and therefore returns all
elements that can be assigned to requested type.findInRange in interface KeyValueOperationspublic long count(KeyValueQuery<?> query, Class<?> type)
KeyValueOperationsKeySpace if present and therefore counts all
elements that can be assigned to requested type.count in interface KeyValueOperationspublic MappingContext<?,?> getMappingContext()
getMappingContext in interface KeyValueOperationspublic void destroy()
throws Exception
destroy in interface DisposableBeanExceptionCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.