Record Class DataResult.Error<T>
java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.common.serialization.DataResult.Error<T>
- Type Parameters:
T- The expected type of the value that failed to resolve.- Record Components:
errorData- The exact runtime failure type evaluated.path- The cumulative path to the failure point.
- All Implemented Interfaces:
DataResult<T>
- Enclosing interface:
DataResult<T>
public static record DataResult.Error<T>(DataError errorData, String path)
extends Record
implements DataResult<T>
The structural implementation of a failed serialization state.
-
Nested Class Summary
Nested classes/interfaces inherited from interface DataResult
DataResult.Error<T>, DataResult.Success<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddWarning(DataError warning) Injects a recorded warning into the execution timeline without forcing a structural failure.final booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorDatarecord component.<R> DataResult<R> flatMap(Function<? super T, ? extends DataResult<? extends R>> mapper) Transforms the wrapped value into a new DataResult using the provided flat-mapping function.Retrieves the value or throws a RuntimeException if this is an error.final inthashCode()Returns a hash code value for this object.booleanisError()booleanboolean<R> DataResult<R> Transforms the wrapped value using the provided mapping function.Transforms the error message if this result represents an error.Retrieves the value, or returns the provided default value if this is an error.path()Returns the value of thepathrecord component.prependPath(String newPath) Prepends a path segment to the error context or recorded warnings to build a complete diagnostic trajectory.result()final StringtoString()Returns a string representation of this record class.warnings()
-
Constructor Details
-
Error
-
-
Method Details
-
isSuccess
public boolean isSuccess()- Specified by:
isSuccessin interfaceDataResult<T>- Returns:
- True if this result represents a success (including partial successes), false otherwise.
-
isError
public boolean isError()- Specified by:
isErrorin interfaceDataResult<T>- Returns:
- True if this result represents an error, false otherwise.
-
isPartial
public boolean isPartial()- Specified by:
isPartialin interfaceDataResult<T>- Returns:
- True if this result is successful but carries recorded warnings.
-
result
- Specified by:
resultin interfaceDataResult<T>- Returns:
- An Optional containing the value if successful, or empty if an error.
-
error
- Specified by:
errorin interfaceDataResult<T>- Returns:
- An Optional containing the formatted error message if an error, or empty if successful.
-
dataError
- Specified by:
dataErrorin interfaceDataResult<T>- Returns:
- An Optional containing the exact DataError type evaluated during deserialization.
-
warnings
- Specified by:
warningsin interfaceDataResult<T>- Returns:
- The collection of recorded warnings if this is a partial result.
-
getOrThrow
Description copied from interface:DataResultRetrieves the value or throws a RuntimeException if this is an error.- Specified by:
getOrThrowin interfaceDataResult<T>- Returns:
- The wrapped value.
-
orElse
Description copied from interface:DataResultRetrieves the value, or returns the provided default value if this is an error.- Specified by:
orElsein interfaceDataResult<T>- Parameters:
defaultValue- The fallback value.- Returns:
- The wrapped value or the default.
-
map
Description copied from interface:DataResultTransforms the wrapped value using the provided mapping function.- Specified by:
mapin interfaceDataResult<T>- Type Parameters:
R- The new value type.- Parameters:
mapper- The transformation logic.- Returns:
- A new DataResult containing the transformed value.
-
flatMap
Description copied from interface:DataResultTransforms the wrapped value into a new DataResult using the provided flat-mapping function. Supports covariant return types to prevent generic capture mismatches.- Specified by:
flatMapin interfaceDataResult<T>- Type Parameters:
R- The new value type.- Parameters:
mapper- The transformation logic that yields a DataResult.- Returns:
- A new DataResult.
-
mapError
Description copied from interface:DataResultTransforms the error message if this result represents an error.- Specified by:
mapErrorin interfaceDataResult<T>- Parameters:
errorMapper- The logic to apply to the existing error message.- Returns:
- A new DataResult with the transformed error.
-
prependPath
Description copied from interface:DataResultPrepends a path segment to the error context or recorded warnings to build a complete diagnostic trajectory.- Specified by:
prependPathin interfaceDataResult<T>- Parameters:
newPath- The path segment to prepend.- Returns:
- A new DataResult reflecting the updated path logic.
-
addWarning
Description copied from interface:DataResultInjects a recorded warning into the execution timeline without forcing a structural failure.- Specified by:
addWarningin interfaceDataResult<T>- Parameters:
warning- The localized diagnostic logging message mapped as an error.- Returns:
- A modified instance retaining the internal value but flagging warning status.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
errorData
-
path
-