Record Class AttributeLookupResult

java.lang.Object
java.lang.Record
org.kiwiproject.beta.base.jar.AttributeLookupResult
Record Components:
lookupStatus - the lookup status
value - the value, or null if the lookup did not succeed for any reason
error - the Exception that 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 Details

    • AttributeLookupResult

      public AttributeLookupResult(AttributeLookupStatus lookupStatus, @Nullable String value, @Nullable Exception error)
      Creates an instance of a AttributeLookupResult record class.
      Parameters:
      lookupStatus - the value for the lookupStatus record component
      value - the value for the value record component
      error - the value for the error record 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

      public Optional<String> maybeValue()
      Returns:
      an Optional wrapping the value
    • valueOrThrow

      public String valueOrThrow()
      Return the attribute value if non-null. Otherwise, throw an IllegalStateException.
      Returns:
      the value if not-null
      Throws:
      IllegalStateException - if value is null
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • lookupStatus

      public AttributeLookupStatus lookupStatus()
      Returns the value of the lookupStatus record component.
      Returns:
      the value of the lookupStatus record component
    • value

      public @Nullable String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • error

      public @Nullable Exception error()
      Returns the value of the error record component.
      Returns:
      the value of the error record component