Package com.celeral.utils
Class StringCodec.Object2String<T>
- java.lang.Object
-
- com.celeral.utils.StringCodec.Object2String<T>
-
- Type Parameters:
T
- Type of the object which is converted to/from String
- All Implemented Interfaces:
StringCodec<T>
,java.io.Serializable
- Enclosing interface:
- StringCodec<T>
public static class StringCodec.Object2String<T> extends java.lang.Object implements StringCodec<T>, java.io.Serializable
The attributes which represent arbitrary objects for which the schema cannot be standardized, we allow them to be represented as <ClassName>:<Constructor_String>:<Property_String> representation. This allows us to instantiate the class by invoking its constructor which takes <String> as argument. If only the <ClassName> is specified, then just the class is instantiated using default constructor. If colon is specified then class is instantiated using constructor with string as an argument. If properties are specified then properties will be set on the object. The properties are defined in property=value format separated by colon(:)- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.celeral.utils.StringCodec
StringCodec.Boolean2String, StringCodec.Class2String<T>, StringCodec.Collection2String<T>, StringCodec.Enum2String<T extends java.lang.Enum<T>>, StringCodec.Integer2String, StringCodec.Long2String, StringCodec.Map2String<K,V>, StringCodec.Object2String<T>, StringCodec.Path2String, StringCodec.Short2String, StringCodec.String2String, StringCodec.URI2String
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
separator
-
Constructor Summary
Constructors Constructor Description Object2String()
Object2String(java.lang.String separator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
fromString(java.lang.String string)
Given a string representation (typically from properties file) for an object , create object from it.static java.lang.Class<?>
loadClass(java.lang.String classname, java.lang.ClassLoader... loaders)
java.lang.String
toString(T pojo)
Given a POJO, serialize it to a String object (typically to be stored in properties file).
-
-
-
Method Detail
-
loadClass
public static java.lang.Class<?> loadClass(java.lang.String classname, java.lang.ClassLoader... loaders) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
fromString
public T fromString(java.lang.String string)
Description copied from interface:StringCodec
Given a string representation (typically from properties file) for an object , create object from it.- Specified by:
fromString
in interfaceStringCodec<T>
- Parameters:
string
- Type of the POJO which is created from String representation.- Returns:
- POJO obtained as a result of deserialization
-
toString
public java.lang.String toString(T pojo)
Description copied from interface:StringCodec
Given a POJO, serialize it to a String object (typically to be stored in properties file).- Specified by:
toString
in interfaceStringCodec<T>
- Parameters:
pojo
- The object which needs to be serialized.- Returns:
- Serialized representation of pojo..
-
-