public class DomainBucket<T> extends Object
Bucket that is strongly typed and uses
a preset ConflictResolver, MutationProducer, Converter, r, w, dw, rw, Retrier,
returnBody etc
If you are working with one specific type of data only it can be simpler to
create a DomainBucket around your bucket. It reduces the amount of
code since the Converter, Mutation, Retrier and
ConflictResolver are likely to be the same for each operation.
Example:
final Bucket b = client.createBucket(bucketName).allowSiblings(true).nVal(3).execute();
final DomainBucket
RiakBucket,
DomainBucketBuilder| Constructor and Description |
|---|
DomainBucket(Bucket bucket,
ConflictResolver<T> resolver,
Converter<T> converter,
MutationProducer<T> mutationProducer,
StoreMeta storeMeta,
FetchMeta fetchMeta,
DeleteMeta deleteMeta,
Class<T> clazz,
Retrier retrier) |
DomainBucket(Bucket bucket,
ConflictResolver<T> resolver,
Converter<T> converter,
MutationProducer<T> mutationProducer,
StoreMeta storeMeta,
FetchMeta fetchMeta,
DeleteMeta deleteMeta,
Class<T> clazz,
Retrier retrier,
boolean withoutFetch)
Create a new
DomainBucket for clazz Class objects
wrapped around bucket
It is recommended to use the DomainBucketBuilder rather than this
constructor. |
| Modifier and Type | Method and Description |
|---|---|
static <T> DomainBucketBuilder<T> |
builder(Bucket b,
Class<T> clazz)
Factory method to create a new
DomainBucketBuilder for the given Bucket and Class. |
void |
delete(String key)
Deprecated.
|
void |
delete(String key,
VClock vclock)
Delete the key/value stored at the
key |
void |
delete(T o)
Delete the key/value stored at the key extracted from
o's
RiakKey annotated field. |
T |
fetch(String key)
Fetch data stored at
key in this bucket as an instance of
T. |
T |
fetch(T o)
|
List<MultiFetchFuture<T>> |
multiFetch(List<T> objs)
Fetch data stored at the keys extracted from each
obj's
RiakKey annotated field as an instance of
T. |
List<MultiFetchFuture<T>> |
multiFetch(String[] keys)
Fetch data stored at
keys in this bucket as a List of
MultiFetchFuture objects that will return instances of T |
T |
store(T o)
Store
o in Riak. |
public DomainBucket(Bucket bucket, ConflictResolver<T> resolver, Converter<T> converter, MutationProducer<T> mutationProducer, StoreMeta storeMeta, FetchMeta fetchMeta, DeleteMeta deleteMeta, Class<T> clazz, Retrier retrier, boolean withoutFetch)
DomainBucket for clazz Class objects
wrapped around bucket
It is recommended to use the DomainBucketBuilder rather than this
constructor.bucket - The bucket to wrap.resolver - the ConflictResolverconverter - the Converter to usemutationProducer - the MutationProducer to usestoreMeta - the set of store parametersfetchMeta - the set of fetch parametersdeleteMeta - the set of delete parametersclazz - the Class type of the DomainBucketretrier - the Retrier to use for each operationwithoutFetch - controls whether a store operation should do a fetch firstStoreObject.withoutFetch()public DomainBucket(Bucket bucket, ConflictResolver<T> resolver, Converter<T> converter, MutationProducer<T> mutationProducer, StoreMeta storeMeta, FetchMeta fetchMeta, DeleteMeta deleteMeta, Class<T> clazz, Retrier retrier)
public T store(T o) throws RiakException
o in Riak.
T must have a field annotated with RiakKey.
This is equivalent to creating and executing a StoreObject
operation with the Converter, ConflictResolver,
Retrier, and a Mutation (from calling
MutationProducer.produce(Object) on o), r, w, dw
etc. passed when the DomainBucket was constructed.
o - instance of TRiakExceptionpublic T fetch(String key) throws RiakException
key in this bucket as an instance of
T.
This is equivalent to creating and executing a FetchObject
configured with the Converter, ConflictResolver,
Retrier and r value specified in the constructor.
key - RiakExceptionpublic T fetch(T o) throws RiakException
o's
RiakKey annotated field as an instance of
T.
This is equivalent to creating and executing a FetchObject
configured with the Converter, ConflictResolver,
Retrier and r value specified in the constructor.
key - RiakExceptionpublic List<MultiFetchFuture<T>> multiFetch(String[] keys)
keys in this bucket as a List of
MultiFetchFuture objects that will return instances of T
This is equivalent to creating and executing a MultiFetchObject
configured with the Converter, ConflictResolver,
Retrier and r value specified in the constructor.
keys - MultiFetchObjectpublic List<MultiFetchFuture<T>> multiFetch(List<T> objs)
obj's
RiakKey annotated field as an instance of
T.
This is equivalent to creating and executing a MultiFetchObject
configured with the Converter, ConflictResolver,
Retrier and r value specified in the constructor.
keys - MultiFetchObjectpublic void delete(T o) throws RiakException
o's
RiakKey annotated field.
This is equivalent to creating and executing a DeleteObject
configured with the Retrier and r value specified in the
constructor.
If a field is annotated with @RiakVClock and not null
the value is used. Otherwise a fetch is performed to retrieve it.
key - RiakException@Deprecated public void delete(String key) throws RiakException
delete(java.lang.String, com.basho.riak.client.cap.VClock)key
This is equivalent to creating and executing a DeleteObject
configured with the Retrier and r value specified in the
constructor. A fetch is performed to get the vclock.
key - the key for the objectRiakExceptionpublic void delete(String key, VClock vclock) throws RiakException
key
This is equivalent to creating and executing a DeleteObject
configured with the Retrier and r value specified in the
constructor. If vclock is null a fetch is performed to get it.
key - the key for the objectvclock - the vclock for the existing objectRiakExceptionpublic static <T> DomainBucketBuilder<T> builder(Bucket b, Class<T> clazz)
DomainBucketBuilder for the given Bucket and Class.b - the Bucket to wrapclazz - the type of object to store/fetch with the new DomainBucketCopyright © 2014. All Rights Reserved.