Interface Serializer<D,​S>

  • Type Parameters:
    D - deserialized type
    S - serialized type
    All Known Subinterfaces:
    Adapter<S,​D>
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Serializer<D,​S>
    Serializes an object.
    • Method Detail

      • serialize

        Optional<S> serialize​(D deserialized)
        Serializes the provided object. If the object cannot be properly serialized, then the result will be empty.

        Note: this should never throw any runtime exceptions or return null. An empty optional should always be returned if serialization fails.

        Parameters:
        deserialized - the object to serialize
        Returns:
        the serialized result if successful, otherwise empty