Interface SerializeOutput

All Superinterfaces:
ConfigurationDefinition.WriteOptions, SerializeContext

public interface SerializeOutput extends SerializeContext
The output for serialization, which is handed to SerializeDeserialize.serialize(V, space.arim.dazzleconf.engine.SerializeOutput).

Serializers MUST call one of the output methods in this class. The output methods start with "out" and are distinguished by the argument type, which helps callers ensure that they are passing a valid output type. If no object is output when serialize returns, that is considered a library usage error, and an exception may be thrown at a later time.

Advanced usage

This SerializeOutput stores the last object output to it. Calling more than one "out" method will overwrite the value stored in this instance, which will in turn change the return value of this method. This output can be extracted (and simultaneously cleared) by calling getAndClearLastOutput().

  • Method Details

    • outString

      void outString(@NonNull String value)
      Outputs a string
      Parameters:
      value - the string, nonnull
    • outBoolean

      void outBoolean(boolean value)
      Outputs a boolean
      Parameters:
      value - the boolean
    • outByte

      void outByte(byte value)
      Outputs a byte
      Parameters:
      value - the byte
    • outChar

      void outChar(char value)
      Outputs a character
      Parameters:
      value - the character
    • outShort

      void outShort(short value)
      Outputs a short
      Parameters:
      value - the short
    • outInt

      void outInt(int value)
      Outputs an integer
      Parameters:
      value - the integer
    • outLong

      void outLong(long value)
      Outputs a long
      Parameters:
      value - the long
    • outFloat

      void outFloat(float value)
      Outputs a float
      Parameters:
      value - the float
    • outDouble

      void outDouble(double value)
      Outputs a double
      Parameters:
      value - the double
    • outDataTree

      void outDataTree(@NonNull DataTree value)
      Outputs a data tree
      Parameters:
      value - the data tree
    • outDataList

      void outDataList(@NonNull DataList value)
      Outputs a data list
      Parameters:
      value - the data list
    • outObjectUnchecked

      void outObjectUnchecked(@NonNull Object value)
      Outputs the given object.

      This function should not be used in normal circumstances. It is a low-level means of setting the output object, intended for when the caller has a ready object but does not know its exact type.

      The caller guarantees that the passed object is valid according to DataEntry.validateValue(Object). If this condition is not met, behavior is not defined and an exception may be thrown at a later point.

      Parameters:
      value - the object
    • getAndClearLastOutput

      @Nullable Object getAndClearLastOutput()
      Gets the last output, clears it in this SerializeOutput, and returns it to the caller.

      Any one of the "out" methods on this type will affect the return value of this method. Whichever was called last will be yielded here, or null if none were called. Because this method also clears the stored value, calling it twice will always yield null.

      Returns:
      the last object output, or null if there is none