Class SerializedValue

  • All Implemented Interfaces:
    org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class SerializedValue
    extends Object
    implements org.joda.beans.ImmutableBean
    A serialized value.

    This bean allows a Java object to be passed around in serialized form. The object can be a Joda-Convert type, a Joda-Bean or implement Serializable. This is useful where an object needs to be transported to another Java process where the object's class may not be on the classpath.

    • Method Detail

      • serialize

        public static <T> SerializedValue serialize​(Class<T> javaType,
                                                    T value)
        Obtains an instance by serializing the value based on the declared Java type.

        The declared Java type is not necessarily the same as the actual type of the value. For example, the declared type might be an interface and the actual type the implementation class.

        Type Parameters:
        T - the type of the value
        Parameters:
        javaType - the declared Java type
        value - the value, may be null, a Joda-Convert type, Joda-Bean, or Serializable
        Returns:
        the value object
        Throws:
        RuntimeException - if the value cannot be stored
      • deserialize

        public <T> T deserialize​(Class<T> javaType)
        Deserializes the value.

        This converts the value from the underlying string or binary form. As such, it might throw an exception. The intention is that deserialization uses the same Java type as serialization.

        Type Parameters:
        T - the type of the value
        Parameters:
        javaType - the declared Java type
        Returns:
        the value, null if the serialized value represents null
        Throws:
        RuntimeException - if the value cannot be deserialized
      • meta

        public static org.joda.beans.TypedMetaBean<SerializedValue> meta()
        The meta-bean for SerializedValue.
        Returns:
        the meta-bean, not null
      • metaBean

        public org.joda.beans.TypedMetaBean<SerializedValue> metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object