Package dev.siroshun.codec4j.api.error
Interface DecodeError
- All Known Subinterfaces:
DecodeError.Failure,DecodeError.FatalError,DecodeError.IgnorableError,DecodeError.InvalidChar,DecodeError.InvalidNumber,DecodeError.InvalidNumberFormat,DecodeError.IterationError,DecodeError.TypeMismatch
- All Known Implementing Classes:
AlreadyDecodedError,Base64Codec.InvalidBase64Error,DuplicatedElementError,EnumCodec.UnknownEnumNameDecodeError,EnumCodec.UnknownEnumOrdinalDecodeError,MapCodec.DuplicatedKeyError,RequiredFieldError,UUIDCodec.InvalidUUIDFormatError
@NotNullByDefault
public sealed interface DecodeError
permits DecodeError.Failure, DecodeError.FatalError, DecodeError.IgnorableError, DecodeError.InvalidChar, DecodeError.InvalidNumber, DecodeError.InvalidNumberFormat, DecodeError.IterationError, DecodeError.TypeMismatch
An interface to indicate errors when decoding.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn interface that indicates aDecodeErrorfor custom error type.static interfaceAn interface that indicates aDecodeErrorwhen fatal error occurred while decoding.static interfaceAn interface that marks aDecodeErroras ignorable.static interfaceAn interface that indicates aDecodeErrorwhen the data is invalidCharacter.static interfaceAn interface that indicates aDecodeErrorwhen the data is invalid number.static interfaceAn interface that indicates aDecodeErrorwhen the data is an invalid number format.static interfaceAn interface that indicates aDecodeErrorwhenResult.Failureis returned when iterating elements.static interfaceAn interface that indicates aDecodeErrorwhen the type is different from the expected type. -
Method Summary
Modifier and TypeMethodDescriptiondefault <T> dev.siroshun.jfun.result.Result.Failure<T, DecodeError> Converts thisDecodeErrortoResult.Failure.default DecodeError.IgnorableErrorMakes thisDecodeErrorignorable.static DecodeError.FatalErrorfatalError(Throwable cause) Creates aDecodeErrorwhen fatal error occurred while decoding.static DecodeError.InvalidCharinvalidChar(String actualValue) Creates aDecodeErrorwhen the data is invalidCharacter.static DecodeError.InvalidNumberinvalidNumber(Type.NumberValue<?> expectedType, Number actualValue) Creates aDecodeErrorwhen the data is invalid number.Creates aDecodeErrorwhen the data is an invalid number format.default booleanReturns whether thisDecodeErrorcan be ignored.static DecodeError.IterationErroriterationError(dev.siroshun.jfun.result.Result.Failure<?, ?> cause) Creates aDecodeErrorwhenResult.Failureis returned when iterating elements.static DecodeError.TypeMismatchtypeMismatch(Type expected, Type actual) Creates aDecodeErrorwhen the type is different from the expected type.
-
Method Details
-
typeMismatch
Creates aDecodeErrorwhen the type is different from the expected type.- Parameters:
expected- the expectedTypeactual- the actualType- Returns:
- a new
DecodeError
-
invalidChar
Creates aDecodeErrorwhen the data is invalidCharacter.- Parameters:
actualValue- the actualString- Returns:
- a new
DecodeError
-
invalidNumber
static DecodeError.InvalidNumber invalidNumber(Type.NumberValue<?> expectedType, Number actualValue) Creates aDecodeErrorwhen the data is invalid number.- Parameters:
expectedType- the expectedType.NumberValueactualValue- the actualNumbervalue- Returns:
- a new
DecodeError
-
invalidNumberFormat
Creates aDecodeErrorwhen the data is an invalid number format.- Parameters:
e- the causedNumberFormatException- Returns:
- a new
DecodeError
-
iterationError
static DecodeError.IterationError iterationError(dev.siroshun.jfun.result.Result.Failure<?, ?> cause) Creates aDecodeErrorwhenResult.Failureis returned when iterating elements.- Parameters:
cause- theResult.Failure- Returns:
- a new
DecodeError
-
fatalError
Creates aDecodeErrorwhen fatal error occurred while decoding.- Parameters:
cause- theThrowablethat caused the error- Returns:
- a new
DecodeError
-
asFailure
Converts thisDecodeErrortoResult.Failure.- Type Parameters:
T- any type- Returns:
- the
Result.Failure
-
asIgnorable
Makes thisDecodeErrorignorable.- Returns:
DecodeError.IgnorableErrorwith thisDecodeError
-
isIgnorable
default boolean isIgnorable()Returns whether thisDecodeErrorcan be ignored.- Returns:
trueif thisDecodeErrorcan be ignored, otherwisefalse
-