Package com.carfey.ops.job.result
Class DefaultSerializationStrategy
- java.lang.Object
-
- com.carfey.ops.job.result.DefaultSerializationStrategy
-
- All Implemented Interfaces:
SerializationStrategy
public class DefaultSerializationStrategy extends java.lang.Object implements SerializationStrategy
The defaultSerializationStrategyused by Obsidian, and the fallback for all cases where another suitable strategy is not found. This strategy generally uses the toString() representation of the object for storage, and invokes a constructor which accepts a single string as its only argument to reconstruct it. Minor exceptions apply for primitive types.- Since:
- 4.4
-
-
Constructor Summary
Constructors Constructor Description DefaultSerializationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tdeserialize(java.lang.Class<T> clazz, java.lang.String strVal)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)Does this strategy support the specified type? Generic implementations may simply always return true.
-
-
-
Method Detail
-
supports
public boolean supports(java.lang.Class<?> clazz)
Description copied from interface:SerializationStrategyDoes this strategy support the specified type? Generic implementations may simply always return 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)
Description 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
-
deserialize
public <T> T deserialize(java.lang.Class<T> clazz, java.lang.String strVal) 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 objectstrVal- (not null) string representation- Returns:
- the reconstructed object
- Throws:
java.lang.Exception- any failure to deserialize
-
-