Interface SerializationWriter

All Superinterfaces:
AutoCloseable, Closeable

public interface SerializationWriter extends Closeable
Defines an interface for serialization of objects to a stream.
  • Method Details

    • writeStringValue

      void writeStringValue(@Nullable String key, @Nullable String value)
      Writes the specified string value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeBooleanValue

      void writeBooleanValue(@Nullable String key, @Nullable Boolean value)
      Writes the specified Boolean value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeByteValue

      void writeByteValue(@Nullable String key, @Nullable Byte value)
      Writes the specified Byte value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeShortValue

      void writeShortValue(@Nullable String key, @Nullable Short value)
      Writes the specified Short value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeBigDecimalValue

      void writeBigDecimalValue(@Nullable String key, @Nullable BigDecimal value)
      Writes the specified BigDecimal value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeIntegerValue

      void writeIntegerValue(@Nullable String key, @Nullable Integer value)
      Writes the specified Integer value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeFloatValue

      void writeFloatValue(@Nullable String key, @Nullable Float value)
      Writes the specified Float value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeDoubleValue

      void writeDoubleValue(@Nullable String key, @Nullable Double value)
      Writes the specified Double value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeLongValue

      void writeLongValue(@Nullable String key, @Nullable Long value)
      Writes the specified Long value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeUUIDValue

      void writeUUIDValue(@Nullable String key, @Nullable UUID value)
      Writes the specified UUID value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeOffsetDateTimeValue

      void writeOffsetDateTimeValue(@Nullable String key, @Nullable OffsetDateTime value)
      Writes the specified OffsetDateTime value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeLocalDateValue

      void writeLocalDateValue(@Nullable String key, @Nullable LocalDate value)
      Writes the specified LocalDate value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeLocalTimeValue

      void writeLocalTimeValue(@Nullable String key, @Nullable LocalTime value)
      Writes the specified LocalTime value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writePeriodAndDurationValue

      void writePeriodAndDurationValue(@Nullable String key, @Nullable PeriodAndDuration value)
      Writes the specified Period/Duration value to the stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeCollectionOfPrimitiveValues

      <T> void writeCollectionOfPrimitiveValues(@Nullable String key, @Nullable Iterable<T> values)
      Writes the specified collection of primitive values to the stream with an optional given key.
      Type Parameters:
      T - the type of the primitive.
      Parameters:
      key - the key to write the value with.
      values - the value to write to the stream.
    • writeCollectionOfObjectValues

      <T extends Parsable> void writeCollectionOfObjectValues(@Nullable String key, @Nullable Iterable<T> values)
      Writes the specified collection of object values to the stream with an optional given key.
      Type Parameters:
      T - the type of the object.
      Parameters:
      key - the key to write the value with.
      values - the value to write to the stream.
    • writeCollectionOfEnumValues

      <T extends Enum<T>> void writeCollectionOfEnumValues(@Nullable String key, @Nullable Iterable<T> values)
      Writes the specified collection of enum values to the stream with an optional given key.
      Type Parameters:
      T - the type of the enum.
      Parameters:
      key - the key to write the value with.
      values - the values to write to the stream.
    • writeObjectValue

      <T extends Parsable> void writeObjectValue(@Nullable String key, @Nullable T value, @Nonnull Parsable... additionalValuesToMerge)
      Writes the specified model object value to the stream with an optional given key.
      Type Parameters:
      T - the type of the model object.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
      additionalValuesToMerge - the additional values to merge to the main value when serializing an intersection wrapper.
    • getSerializedContent

      @Nonnull InputStream getSerializedContent()
      Gets the value of the serialized content.
      Returns:
      the value of the serialized content.
    • writeEnumSetValue

      <T extends Enum<T>> void writeEnumSetValue(@Nullable String key, @Nullable EnumSet<T> values)
      Writes the specified enum set value to the stream with an optional given key.
      Type Parameters:
      T - the type of the enum.
      Parameters:
      key - the key to write the value with.
      values - the value to write to the stream.
    • writeEnumValue

      <T extends Enum<T>> void writeEnumValue(@Nullable String key, @Nullable T value)
      Writes the specified enum value to the stream with an optional given key.
      Type Parameters:
      T - the type of the enum.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.
    • writeNullValue

      void writeNullValue(@Nullable String key)
      Writes a null value for the specified key.
      Parameters:
      key - the key to write the value with.
    • writeAdditionalData

      void writeAdditionalData(@Nonnull Map<String,Object> value)
      Writes the specified additional data values to the stream with an optional given key.
      Parameters:
      value - the values to write to the stream.
    • getOnBeforeObjectSerialization

      @Nullable Consumer<Parsable> getOnBeforeObjectSerialization()
      Gets the callback called before the object gets serialized.
      Returns:
      the callback called before the object gets serialized.
    • getOnAfterObjectSerialization

      @Nullable Consumer<Parsable> getOnAfterObjectSerialization()
      Gets the callback called after the object gets serialized.
      Returns:
      the callback called after the object gets serialized.
    • getOnStartObjectSerialization

      @Nullable BiConsumer<Parsable,SerializationWriter> getOnStartObjectSerialization()
      Gets the callback called right after the serialization process starts.
      Returns:
      the callback called right after the serialization process starts.
    • setOnBeforeObjectSerialization

      void setOnBeforeObjectSerialization(@Nullable Consumer<Parsable> value)
      Sets the callback called before the objects gets serialized.
      Parameters:
      value - the callback called before the objects gets serialized.
    • setOnAfterObjectSerialization

      void setOnAfterObjectSerialization(@Nullable Consumer<Parsable> value)
      Sets the callback called after the objects gets serialized.
      Parameters:
      value - the callback called after the objects gets serialized.
    • setOnStartObjectSerialization

      void setOnStartObjectSerialization(@Nullable BiConsumer<Parsable,SerializationWriter> value)
      Sets the callback called right after the serialization process starts.
      Parameters:
      value - the callback called right after the serialization process starts.
    • writeByteArrayValue

      void writeByteArrayValue(@Nullable String key, @Nonnull byte[] value)
      Writes the byte array value to the current stream with an optional given key.
      Parameters:
      key - the key to write the value with.
      value - the value to write to the stream.