Class DefaultSerializationStrategy

  • All Implemented Interfaces:
    SerializationStrategy

    public class DefaultSerializationStrategy
    extends java.lang.Object
    implements SerializationStrategy
    The default SerializationStrategy used 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 Detail

      • DefaultSerializationStrategy

        public DefaultSerializationStrategy()
    • Method Detail

      • supports

        public boolean supports​(java.lang.Class<?> clazz)
        Description copied from interface: SerializationStrategy
        Does this strategy support the specified type? Generic implementations may simply always return true.
        Specified by:
        supports in interface SerializationStrategy
        Returns:
        whether this strategy supports serializing and deserializing the type.
      • deserialize

        public <T> T deserialize​(java.lang.Class<T> clazz,
                                 java.lang.String strVal)
                          throws java.lang.Exception
        Description copied from interface: SerializationStrategy
        Reconstructs the object from its string representation, which was created by SerializationStrategy.serialize(Object).
        Specified by:
        deserialize in interface SerializationStrategy
        Parameters:
        clazz - (not null) type of object
        strVal - (not null) string representation
        Returns:
        the reconstructed object
        Throws:
        java.lang.Exception - any failure to deserialize