Interface SerialSource


public interface SerialSource
Where a codec reads one object's field values back.

The mirror of SerialSink: the same calls in the same order read what they wrote.

Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    claim(Object instance)
    Registers the instance being built, before any of its fields are read.
    boolean
    Returns the next value.
    byte
    Returns the next value.
    char
    Returns the next value.
    double
    Returns the next value.
    float
    Returns the next value.
    int
    Returns the next value.
    long
    Returns the next value.
    <T> T
    readObject(Class<T> type)
    Reads a reference.
    short
    Returns the next value.
  • Method Details

    • readBoolean

      boolean readBoolean()
      Returns the next value.
      Returns:
      the next value
    • readByte

      byte readByte()
      Returns the next value.
      Returns:
      the next value
    • readChar

      char readChar()
      Returns the next value.
      Returns:
      the next value
    • readShort

      short readShort()
      Returns the next value.
      Returns:
      the next value
    • readInt

      int readInt()
      Returns the next value.
      Returns:
      the next value
    • readLong

      long readLong()
      Returns the next value.
      Returns:
      the next value
    • readFloat

      float readFloat()
      Returns the next value.
      Returns:
      the next value
    • readDouble

      double readDouble()
      Returns the next value.
      Returns:
      the next value
    • readObject

      <T> T readObject(Class<T> type)
      Reads a reference.
      Type Parameters:
      T - the type
      Parameters:
      type - what the field is declared as, which is what the value is checked against
      Returns:
      the value, or null
    • claim

      void claim(Object instance)
      Registers the instance being built, before any of its fields are read.

      What makes a cycle work. A field that points back at the object holding it reads as a reference to a handle, and that handle has to already name the instance. A codec that builds its object from field values cannot do that, so it calls this the moment it has an object at all and before the first readObject(java.lang.Class<T>).

      A record never needs it: its components are final and set by the constructor, so a record cannot hold a reference to itself in the first place.

      Parameters:
      instance - the object being built