Package com.carfey.ops.job.result
Class JsonSerializationStrategy
- java.lang.Object
-
- com.carfey.ops.job.result.JsonSerializationStrategy
-
- All Implemented Interfaces:
SerializationStrategy
public class JsonSerializationStrategy extends java.lang.Object implements SerializationStrategy
ASerializationStrategywhich uses Google's Gson to serialize all types of objects. Note that generic collections of complex objects are not supported.- Since:
- 4.4
-
-
Constructor Summary
Constructors Constructor Description JsonSerializationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tdeserialize(java.lang.Class<T> clazz, java.lang.String value)Reconstructs the object from its string representation, which was created bySerializationStrategy.serialize(Object).java.lang.Stringserialize(java.lang.Object obj)Converts the object to its string representation which can be supplied toSerializationStrategy.deserialize(Class, String)to reconstruct the object.booleansupports(java.lang.Class<?> clazz)Always returns true.
-
-
-
Method Detail
-
supports
public boolean supports(java.lang.Class<?> clazz)
Always returns true.- Specified by:
supportsin interfaceSerializationStrategy- Returns:
- whether this strategy supports serializing and deserializing the type.
-
serialize
public java.lang.String serialize(java.lang.Object obj) throws java.lang.ExceptionDescription copied from interface:SerializationStrategyConverts the object to its string representation which can be supplied toSerializationStrategy.deserialize(Class, String)to reconstruct the object.- Specified by:
serializein interfaceSerializationStrategy- Parameters:
obj- (not null)- Returns:
- string representation of the object
- Throws:
java.lang.Exception- any failure to serialize
-
deserialize
public <T> T deserialize(java.lang.Class<T> clazz, java.lang.String value) throws java.lang.ExceptionDescription copied from interface:SerializationStrategyReconstructs the object from its string representation, which was created bySerializationStrategy.serialize(Object).- Specified by:
deserializein interfaceSerializationStrategy- Parameters:
clazz- (not null) type of objectvalue- (not null) string representation- Returns:
- the reconstructed object
- Throws:
java.lang.Exception- any failure to deserialize
-
-