Package org.kiwiproject.beta.base.jar
Record Class AttributeLookupResult
java.lang.Object
java.lang.Record
org.kiwiproject.beta.base.jar.AttributeLookupResult
- Record Components:
lookupStatus- the lookup statusvalue- the value, or null if the lookup did not succeed for any reasonerror- theExceptionthat occurred during a failed lookup, or null if the cause was not an exception
public record AttributeLookupResult(AttributeLookupStatus lookupStatus, @Nullable String value, @Nullable Exception error)
extends Record
A record that contains a lookup status and, if the lookup succeeded, a value.
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeLookupResult(AttributeLookupStatus lookupStatus, @Nullable String value, @Nullable Exception error) Creates an instance of aAttributeLookupResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal booleanIndicates whether some other object is "equal to" this one.@Nullable Exceptionerror()Returns the value of theerrorrecord component.booleanfailed()final inthashCode()Returns a hash code value for this object.Returns the value of thelookupStatusrecord component.booleanCheck if the lookup succeeded; a successful lookup occurs only when the attribute exists and has a value.final StringtoString()Returns a string representation of this record class.@Nullable Stringvalue()Returns the value of thevaluerecord component.Return the attribute value if non-null.
-
Constructor Details
-
AttributeLookupResult
public AttributeLookupResult(AttributeLookupStatus lookupStatus, @Nullable String value, @Nullable Exception error) Creates an instance of aAttributeLookupResultrecord class.- Parameters:
lookupStatus- the value for thelookupStatusrecord componentvalue- the value for thevaluerecord componenterror- the value for theerrorrecord component
-
-
Method Details
-
failed
public boolean failed()- Returns:
- true if the lookup failed for any reason, otherwise true
-
succeeded
public boolean succeeded()Check if the lookup succeeded; a successful lookup occurs only when the attribute exists and has a value.- Returns:
- true if the lookup succeeded, otherwise false
-
containsValue
public boolean containsValue()- Returns:
- true if, and only if, the value is not null
-
maybeValue
- Returns:
- an Optional wrapping the value
-
valueOrThrow
Return the attribute value if non-null. Otherwise, throw anIllegalStateException.- Returns:
- the value if not-null
- Throws:
IllegalStateException- if value is null
-
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). -
lookupStatus
Returns the value of thelookupStatusrecord component.- Returns:
- the value of the
lookupStatusrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-