Package dev.siroshun.codec4j.api.io
Interface In
public interface In
An interface for reading and decoding data from various sources.
This interface provides methods to read primitive types, strings, lists, and maps
from an underlying data source. All methods return a Result that either
contains the successfully decoded value or a DecodeError if the operation failed.
-
Method Summary
Modifier and TypeMethodDescription@NotNull dev.siroshun.jfun.result.Result<Boolean, DecodeError> Reads the current value as aBoolean.@NotNull dev.siroshun.jfun.result.Result<Byte, DecodeError> Reads the current value as aByte.@NotNull dev.siroshun.jfun.result.Result<Character, DecodeError> Reads the current value as aCharacter.@NotNull dev.siroshun.jfun.result.Result<Double, DecodeError> Reads the current value as aDouble.@NotNull dev.siroshun.jfun.result.Result<Float, DecodeError> Reads the current value as aFloat.@NotNull dev.siroshun.jfun.result.Result<Integer, DecodeError> Reads the current value as anInteger.@NotNull dev.siroshun.jfun.result.Result<Long, DecodeError> Reads the current value as aLong.@NotNull dev.siroshun.jfun.result.Result<Short, DecodeError> Reads the current value as aShort.@NotNull dev.siroshun.jfun.result.Result<String, DecodeError> Reads the current value as aString.<R> @NotNull dev.siroshun.jfun.result.Result<R, DecodeError> readList(R identity, @NotNull BiFunction<R, ? super In, dev.siroshun.jfun.result.Result<?, ?>> operator) Reads the current value as a list, using the provided identity object and operator.<R> @NotNull dev.siroshun.jfun.result.Result<R, DecodeError> readMap(R identity, @NotNull BiFunction<R, ? super EntryIn, dev.siroshun.jfun.result.Result<?, ?>> operator) Reads the current value as a map, using the provided identity object and operator.@NotNull dev.siroshun.jfun.result.Result<Type, DecodeError> type()Returns the type of the current value.
-
Method Details
-
type
Returns the type of the current value.- Returns:
- a result containing the
Typeof the current value, or aDecodeErrorif the operation failed
-
readAsBoolean
Reads the current value as aBoolean.- Returns:
- a result containing the
Booleanvalue, or aDecodeErrorif the operation failed
-
readAsByte
Reads the current value as aByte.- Returns:
- a result containing the
Bytevalue, or aDecodeErrorif the operation failed
-
readAsChar
Reads the current value as aCharacter.- Returns:
- a result containing the
Charactervalue, or aDecodeErrorif the operation failed
-
readAsDouble
Reads the current value as aDouble.- Returns:
- a result containing the
Doublevalue, or aDecodeErrorif the operation failed
-
readAsFloat
Reads the current value as aFloat.- Returns:
- a result containing the
Floatvalue, or aDecodeErrorif the operation failed
-
readAsInt
Reads the current value as anInteger.- Returns:
- a result containing the
Integervalue, or aDecodeErrorif the operation failed
-
readAsLong
Reads the current value as aLong.- Returns:
- a result containing the
Longvalue, or aDecodeErrorif the operation failed
-
readAsShort
Reads the current value as aShort.- Returns:
- a result containing the
Shortvalue, or aDecodeErrorif the operation failed
-
readAsString
Reads the current value as aString.- Returns:
- a result containing the
Stringvalue, or aDecodeErrorif the operation failed
-
readList
@NotNull <R> @NotNull dev.siroshun.jfun.result.Result<R,DecodeError> readList(@NotNull R identity, @NotNull @NotNull BiFunction<R, ? super In, dev.siroshun.jfun.result.Result<?, ?>> operator) Reads the current value as a list, using the provided identity object and operator.- Type Parameters:
R- the type of the result container- Parameters:
identity- an object that is used while processing the list elements, and will be returned as the resultoperator- a function that processes each element in the list using the providedIninterface- Returns:
- a result containing the constructed container, or a
DecodeErrorif the operation failed
-
readMap
@NotNull <R> @NotNull dev.siroshun.jfun.result.Result<R,DecodeError> readMap(@NotNull R identity, @NotNull @NotNull BiFunction<R, ? super EntryIn, dev.siroshun.jfun.result.Result<?, ?>> operator) Reads the current value as a map, using the provided identity object and operator.- Type Parameters:
R- the type of the result container- Parameters:
identity- an object that is used while processing the map entries, and will be returned as the resultoperator- a function that processes each entry in the map using the providedEntryIninterface- Returns:
- a result containing the constructed container, or a
DecodeErrorif the operation failed
-