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)
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)
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)
|
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)
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 operationpublic 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 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.
key - RiakExceptionpublic void delete(String key) throws RiakException
key
This is equivalent to creating and executing a DeleteObject
configured with the Retrier and r value specified in the
constructor.
key - RiakExceptionpublic 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 © 2012. All Rights Reserved.