SMILA (incubation) API documentation

org.eclipse.smila.datamodel.util
Class AnyUtil

java.lang.Object
  extended by org.eclipse.smila.datamodel.util.AnyUtil

public final class AnyUtil
extends java.lang.Object

utility class for handling / conversion of Any objects. Hint: The Any-to-JSON conversion for Date(Time)s is not symmetric. If the Any object contains Date(Time) values, they will be serialized to String values in simple timestamp format. But when parsing JSON to an Any object, Date(Time) strings will not be recognized anymore, but just read as String values.


Field Summary
static AnyMap EMPTY_MAP
          Immutable empty AnyMap instance.
 
Method Summary
static java.lang.Object anyToNative(Any any)
          Converts an Any object into a native java object.
static AnyMap exceptionToAny(java.lang.Throwable e)
          convert an exception to an any object.
static Any objectToAny(java.lang.Object object)
          Converts an object to an Any.
static Any saveGet(Any any, java.lang.String[] path)
          get value for given path(list of keys) from AnyMap object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_MAP

public static final AnyMap EMPTY_MAP
Immutable empty AnyMap instance.

Method Detail

anyToNative

public static java.lang.Object anyToNative(Any any)
Converts an Any object into a native java object.

Parameters:
any - the Any object
Returns:
a Pojo

objectToAny

public static Any objectToAny(java.lang.Object object)
Converts an object to an Any.

Parameters:
object - The object to be converted. Maps inside this object have to be Map<String, ?>
Returns:
The converted Any

saveGet

public static Any saveGet(Any any,
                          java.lang.String[] path)
get value for given path(list of keys) from AnyMap object. This methods throws no exception, if the path not exists an empty Any is the result.

Parameters:
any - the Any object.
path - path to the entry.
Returns:
value associated to the path.

exceptionToAny

public static AnyMap exceptionToAny(java.lang.Throwable e)
convert an exception to an any object.

Parameters:
e - exception to convert
Returns:
any representation of exception

SMILA (incubation) API documentation