Interface PreferenceSerializer<S,​T>

  • Type Parameters:
    S - the runtime type.
    T - the persistent type. must be one of boolean, byte, short, char, int, long, float, double or String.
    All Known Implementing Classes:
    EnumPreferenceSerializer

    public interface PreferenceSerializer<S,​T>
    An interface for converting between two types. See Preference.serializer() for more information.
    See Also:
    Preference.serializer()
    • Method Detail

      • serialize

        T serialize​(S value)
             throws PreferenceSerializationException
        Convert from runtime type to persistent type. If the persistent type is a primitive (wrapper) the return value must not be null.
        Parameters:
        value - an object of the runtime type
        Returns:
        the persistent type representation of the parameter
        Throws:
        PreferenceSerializationException - if the object could not be serialized
      • deserialize

        S deserialize​(T value)
               throws PreferenceSerializationException
        Convert from persistent type to runtime type. If the persistent type is a primitive (wrapper) the parameter is guaranteed to not be null
        Parameters:
        value - an object of the persistent type
        Returns:
        the runtime type value of the parameter
        Throws:
        PreferenceSerializationException - if the object could not be deserialized