Class DataSerializer.OptionalDataSerializer<T>

java.lang.Object
ru.progrm_jarvis.javacommons.data.DataSerializer.OptionalDataSerializer<T>
All Implemented Interfaces:
DataSerializer<@NotNull Optional<T>>
Enclosing interface:
DataSerializer<T>

public static final class DataSerializer.OptionalDataSerializer<T> extends Object implements DataSerializer<@NotNull Optional<T>>
Data serializer for optional types.
  • Method Details

    • write

      public void write(@NotNull @NotNull DataOutputStream output, @NotNull @NotNull Optional<T> object) throws IOException
      Description copied from interface: DataSerializer
      Writes the object into the given output stream.
      Specified by:
      write in interface DataSerializer<T>
      Parameters:
      output - output in which the output should be written
      object - object to be written into the output stream
      Throws:
      IOException - if an error happens while writing
    • read

      @NotNull public @NotNull Optional<T> read(@NotNull @NotNull DataInputStream input) throws IOException
      Description copied from interface: DataSerializer
      Reads the object from the given input stream.
      Specified by:
      read in interface DataSerializer<T>
      Parameters:
      input - input from which the object should be read
      Returns:
      read object
      Throws:
      IOException - if an error happens while reading