com.basho.riak.client.builders
Class RiakObjectBuilder

java.lang.Object
  extended by com.basho.riak.client.builders.RiakObjectBuilder

public class RiakObjectBuilder
extends Object

Creates instances of DefaultRiakObject

Author:
russell

Method Summary
 RiakObjectBuilder addIndex(String index, int value)
          Add a RiakIndex to the new riak object's collection.
 RiakObjectBuilder addIndex(String index, String value)
          Add a RiakIndex to the new riak object's collection.
 RiakObjectBuilder addLink(String bucket, String key, String tag)
          Add a RiakLink to the new riak object's collection.
 RiakObjectBuilder addUsermeta(String key, String value)
          Add an item of user meta data to the collection for the new Riak object.
 IRiakObject build()
          Construct a DefaultRiakObject from this builders parameters
static RiakObjectBuilder from(IRiakObject o)
          Creates a builder prepopulated from the give IRiakObject.
static RiakObjectBuilder newBuilder(String bucket, String key)
          Static factory method
 RiakObjectBuilder withContentType(String contentType)
          The content-type of the data payload of the new Riak object.
 RiakObjectBuilder withIndexes(RiakIndexes indexes)
          A Collection of RiakIndexes for the new riak object
 RiakObjectBuilder withLastModified(long lastModified)
          A long timestamp of milliseconds since the epoch to set as the last modified date on this Riak object
 RiakObjectBuilder withLinks(Collection<RiakLink> links)
          A Collection of RiakLinks for the new riak object
 RiakObjectBuilder withUsermeta(Map<String,String> usermeta)
          A map of user meta data to set on the new riak object.
 RiakObjectBuilder withValue(byte[] value)
          The value to give the constructed riak object
 RiakObjectBuilder withValue(String value)
          Convenience method assumes a UTF-8 encoded string
 RiakObjectBuilder withVClock(byte[] vclock)
          The vector clock value for the constructed riak object
 RiakObjectBuilder withVClock(VClock vclock)
          The new Riak objects vector clock.
 RiakObjectBuilder withVtag(String vtag)
          The version tag for this riak object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newBuilder

public static RiakObjectBuilder newBuilder(String bucket,
                                           String key)
Static factory method

Parameters:
bucket -
key -
Returns:
a new RiakObjectBuilder

from

public static RiakObjectBuilder from(IRiakObject o)
Creates a builder prepopulated from the give IRiakObject.

Parameters:
o - the IRiakObject to copy
Returns:
a RiakObjectBuilder with all fields set from o

build

public IRiakObject build()
Construct a DefaultRiakObject from this builders parameters

Returns:
an IRiakObject with the values from this builder.

withValue

public RiakObjectBuilder withValue(byte[] value)
The value to give the constructed riak object

Parameters:
value - byte[] or null. NOTE: will be cloned.
Returns:
this

withValue

public RiakObjectBuilder withValue(String value)
Convenience method assumes a UTF-8 encoded string

Parameters:
value - a UTF-8 encoded string
Returns:
this

withVClock

public RiakObjectBuilder withVClock(byte[] vclock)
The vector clock value for the constructed riak object

Parameters:
vclock - the byte[] of a vector clock: NOTE: will be cloned.
Returns:
this
Throws:
IllegalArgumentException - for a null vclock

withVtag

public RiakObjectBuilder withVtag(String vtag)
The version tag for this riak object

Parameters:
vtag -
Returns:
this

withLastModified

public RiakObjectBuilder withLastModified(long lastModified)
A long timestamp of milliseconds since the epoch to set as the last modified date on this Riak object

Parameters:
lastModified -
Returns:

withLinks

public RiakObjectBuilder withLinks(Collection<RiakLink> links)
A Collection of RiakLinks for the new riak object

Parameters:
links - the Collection of RiakLinks for the Riak object, is copied over the current collection, not merged! NOTE: this will be copied.
Returns:
this

addLink

public RiakObjectBuilder addLink(String bucket,
                                 String key,
                                 String tag)
Add a RiakLink to the new riak object's collection.

Parameters:
bucket - the bucket at the end of the link
key - the key at the end of the link
tag - the link tag
Returns:
this

withIndexes

public RiakObjectBuilder withIndexes(RiakIndexes indexes)
A Collection of RiakIndexes for the new riak object

Parameters:
indexes - the Collection of RiakIndexes for the Riak object, is copied over the current collection, not merged! NOTE: this will be copied.
Returns:
this

addIndex

public RiakObjectBuilder addIndex(String index,
                                  int value)
Add a RiakIndex to the new riak object's collection.

Parameters:
index - the RiakIndex to add
Returns:
this

addIndex

public RiakObjectBuilder addIndex(String index,
                                  String value)
Add a RiakIndex to the new riak object's collection.

Parameters:
index - the RiakIndex to add
Returns:
this

withUsermeta

public RiakObjectBuilder withUsermeta(Map<String,String> usermeta)
A map of user meta data to set on the new riak object.

Parameters:
usermeta - a Map, copied over the current user meta (not merged): NOTE: is copied.
Returns:
this

addUsermeta

public RiakObjectBuilder addUsermeta(String key,
                                     String value)
Add an item of user meta data to the collection for the new Riak object.

Parameters:
key -
value -
Returns:
this

withContentType

public RiakObjectBuilder withContentType(String contentType)
The content-type of the data payload of the new Riak object.

Parameters:
contentType -
Returns:
this

withVClock

public RiakObjectBuilder withVClock(VClock vclock)
The new Riak objects vector clock.

Parameters:
vclock -
Returns:
this


Copyright © 2012. All Rights Reserved.