com.basho.riak.client.convert
Class KeyUtil

java.lang.Object
  extended by com.basho.riak.client.convert.KeyUtil

public class KeyUtil
extends Object

Static methods to get /set the annotated key from/on a domain object.

Author:
russell
See Also:
RiakKey, JSONConverter

Constructor Summary
KeyUtil()
           
 
Method Summary
static
<T> String
getKey(T domainObject)
          Attempts to get a key from domainObject by looking for a RiakKey annotated field.
static
<T> String
getKey(T domainObject, String defaultKey)
          Attempts to get a key from domainObject by looking for a RiakKey annotated field.
static
<T> T
setKey(T domainObject, String key)
          Attempts to inject key as the value of the RiakKey annotated field of domainObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyUtil

public KeyUtil()
Method Detail

setKey

public static <T> T setKey(T domainObject,
                           String key)
                throws ConversionException
Attempts to inject key as the value of the RiakKey annotated field of domainObject

Type Parameters:
T - the type of domainObject
Parameters:
domainObject - the object to inject the key into
key - the key to inject
Returns:
domainObject with RiakKey annotated field set to key
Throws:
ConversionException - if there is a RiakKey annotated field but it cannot be set to the value of key

getKey

public static <T> String getKey(T domainObject,
                                String defaultKey)
Attempts to get a key from domainObject by looking for a RiakKey annotated field. If non-present it simply returns defaultKey

Type Parameters:
T - the type of domainObject
Parameters:
domainObject - the object to search for a key
defaultKey - the pass through value that will get returned if no key found on domainObject
Returns:
either the value found on domainObject;s RiakKey field or defaultkey

getKey

public static <T> String getKey(T domainObject)
Attempts to get a key from domainObject by looking for a RiakKey annotated field. If non-present it simply returns null

Type Parameters:
T - the type of domainObject
Parameters:
domainObject - the object to search for a key
Returns:
either the value found on domainObject;s RiakKey field or null


Copyright © 2012. All Rights Reserved.