Package org.cy3sbml.util
Record Class FetchResult<T>
java.lang.Object
java.lang.Record
org.cy3sbml.util.FetchResult<T>
The result of a fetch: its
FetchStatus and the value, if found.
The value is present if, and only if, the status is FetchStatus.FOUND. A fetch
that got no value (e.g. an empty or missing response body) is an error, not a found
null: callers map it to error() before creating a result.
-
Constructor Summary
ConstructorsConstructorDescriptionFetchResult(FetchStatus status, Optional<T> value) Creates an instance of aFetchResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static <T> FetchResult<T>error()A transient error, e.g. a timeout, which is not cached.static <T> FetchResult<T>found(T value) A found value.final inthashCode()Returns a hash code value for this object.static <T> FetchResult<T>notFound()A deterministic "not found", e.g. an HTTP 404, which may be cached for a short time.status()Returns the value of thestatusrecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
FetchResult
Creates an instance of aFetchResultrecord class.- Parameters:
status- the value for thestatusrecord componentvalue- the value for thevaluerecord component
-
-
Method Details
-
found
A found value.- Throws:
IllegalArgumentException- ifvalueis null: a fetch without a value is anerror()
-
notFound
A deterministic "not found", e.g. an HTTP 404, which may be cached for a short time.- Type Parameters:
T- the value type- Returns:
- the result
-
error
A transient error, e.g. a timeout, which is not cached.- Type Parameters:
T- the value type- Returns:
- the result
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
status
Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-