Package dev.siroshun.codec4j.api.io
Interface Out<O>
- Type Parameters:
O- the type of the output destination
public interface Out<O>
An interface for writing and encoding data to various destinations.
This interface provides methods to write primitive types, strings, lists, and maps
to an underlying data destination. All methods return a Result that either
contains the successfully encoded value or an EncodeError if the operation failed.
-
Method Summary
Modifier and TypeMethodDescription@NotNull dev.siroshun.jfun.result.Result<ElementAppender<O>, EncodeError> Creates a new list in the output destination.@NotNull dev.siroshun.jfun.result.Result<EntryAppender<O>, EncodeError> Creates a new map in the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeBoolean(boolean value) Writes aBooleanvalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeByte(byte value) Writes aBytevalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeChar(char value) Writes aCharactervalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeDouble(double value) Writes aDoublevalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeFloat(float value) Writes aFloatvalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeInt(int value) Writes anIntegervalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeLong(long value) Writes aLongvalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeShort(short value) Writes aShortvalue to the output destination.@NotNull dev.siroshun.jfun.result.Result<O, EncodeError> writeString(@NotNull String value) Writes aStringvalue to the output destination.
-
Method Details
-
writeBoolean
Writes aBooleanvalue to the output destination.- Parameters:
value- theBooleanvalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeByte
Writes aBytevalue to the output destination.- Parameters:
value- theBytevalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeChar
Writes aCharactervalue to the output destination.- Parameters:
value- theCharactervalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeDouble
Writes aDoublevalue to the output destination.- Parameters:
value- theDoublevalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeFloat
Writes aFloatvalue to the output destination.- Parameters:
value- theFloatvalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeInt
Writes anIntegervalue to the output destination.- Parameters:
value- theIntegervalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeLong
Writes aLongvalue to the output destination.- Parameters:
value- theLongvalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeShort
Writes aShortvalue to the output destination.- Parameters:
value- theShortvalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
writeString
@NotNull @NotNull dev.siroshun.jfun.result.Result<O,EncodeError> writeString(@NotNull @NotNull String value) Writes aStringvalue to the output destination.- Parameters:
value- theStringvalue to write- Returns:
- a result containing the output destination, or an
EncodeErrorif the operation failed
-
createList
Creates a new list in the output destination.- Returns:
- a result containing an
ElementAppenderfor adding elements to the list, or anEncodeErrorif the operation failed
-
createMap
Creates a new map in the output destination.- Returns:
- a result containing an
EntryAppenderfor adding key-value pairs to the map,or anEncodeErrorif the operation failed
-