Class Serializer
java.lang.Object
us.irdev.bedrock.bag.Serializer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <WorkingType>
WorkingTypefromBagAsType(Bag bag, Class type) Reconstitute the given BagObject representation back to the object it represents, using a "best-effort" approach to matching the fields of the BagObject to the class being initialized.static <WorkingType>
WorkingTypefromBagObject(BagObject bagObject) Reconstitute the given BagObject representation back to the object it represents.static BagObjecttoBagObject(Object object) Convert the given object to a BagObject representation that can be used to reconstitute the given object after serialization.static BagObjectReturn the @value component of a serialized object
-
Field Details
-
TYPE_KEY
- See Also:
-
VERSION_KEY
- See Also:
-
KEY_KEY
- See Also:
-
VALUE_KEY
- See Also:
-
SERIALIZER_VERSION_1
- See Also:
-
SERIALIZER_VERSION_2
- See Also:
-
SERIALIZER_VERSION_3
- See Also:
-
SERIALIZER_VERSION_4
- See Also:
-
SERIALIZER_VERSION_5
- See Also:
-
SERIALIZER_VERSION
- See Also:
-
-
Constructor Details
-
Serializer
public Serializer()
-
-
Method Details
-
Unwrap
-
toBagObject
Convert the given object to a BagObject representation that can be used to reconstitute the given object after serialization.- Parameters:
object- the target element to serialize. It must be one of the following: primitive, boxed-primitive, Plain Old Java Object (POJO) class, object class with getters and setters for all members, BagObject, BagArray, array, or list or map-based container of one of the previously mentioned types.- Returns:
- A BagObject encapsulation of the target object, or null if the conversion failed.
-
fromBagObject
Reconstitute the given BagObject representation back to the object it represents.- Type Parameters:
WorkingType- template parameter for the type to return- Parameters:
bagObject- the target BagObject to deserialize. It must be a valid representation of the encoded type(i.e. created by the toBagObject method).- Returns:
- the reconstituted object, or null if the reconstitution failed.
-
fromBagAsType
Reconstitute the given BagObject representation back to the object it represents, using a "best-effort" approach to matching the fields of the BagObject to the class being initialized.- Parameters:
bag- The input data to reconstruct from, either a BagObject or BagArraytype- the Class representing the type to reconstruct- Returns:
- the reconstituted object, or null if the reconstitution failed.
-