Package dev.gmitch215.bytebox.io
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 TypeMethodDescriptionvoidRegisters the instance being built, before any of its fields are read.booleanReturns the next value.bytereadByte()Returns the next value.charreadChar()Returns the next value.doubleReturns the next value.floatReturns the next value.intreadInt()Returns the next value.longreadLong()Returns the next value.<T> TreadObject(Class<T> type) Reads a reference.shortReturns 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
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
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
-