Package dev.turboism.sdk.storage
Record Class StorageReadResult<T>
java.lang.Object
java.lang.Record
dev.turboism.sdk.storage.StorageReadResult<T>
- Type Parameters:
T- value type returned by the read operation- Record Components:
value- successfully read value, present exactly whenerroris emptyerror- structured failure, present exactly whenvalueis emptytruncated- whether a successful read stopped at its requested byte limit
public record StorageReadResult<T>(Optional<T> value, Optional<StorageError> error, boolean truncated)
extends Record
Structured result of one bounded storage read.
-
Constructor Summary
ConstructorsConstructorDescriptionStorageReadResult(Optional<T> value, Optional<StorageError> error, boolean truncated) Validates result presence and defensively copies a byte-array value. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.booleanReturns the value of thetruncatedrecord component.value()Returns the successful value, copying byte arrays on every access.
-
Constructor Details
-
StorageReadResult
Validates result presence and defensively copies a byte-array value.- Parameters:
value- optional successful valueerror- optional structured errortruncated- whether a successful read stopped at its limit- Throws:
NullPointerException- if an optional container isnullIllegalArgumentException- if both or neither value and error are present, or a failed result is marked truncated
-
-
Method Details
-
value
Returns the successful value, copying byte arrays on every access.- Returns:
- the value optional; a returned
byte[]is caller-owned and may be mutated
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-
truncated
public boolean truncated()Returns the value of thetruncatedrecord component.- Returns:
- the value of the
truncatedrecord component
-