Class AttributeValues
Client.getAttributes(String, AttributeRead...) call.
getAttributes returns an AttributeValues only after every set value has
decoded. Look up each value with get(AttributeRead), passing the read that was part of
the call or an equal one. An Attribute matches only the same definition object. An
AttributeMapInstance matches any selector for the same AttributeMap object and
the same instance key, so a freshly created notes.instance("n1") works.
An unset Attribute or AttributeMap instance reads as Optional.empty(). Falsy values
such as an empty string, 0, and false are set values. A stored value that
decodes to null also reads as Optional.empty(), because Optional cannot
hold null. Writing null from a Step or RPC deletes the Attribute, so this case
is rare.
An AttributeValues cannot change after the call returns, and threads may share it.
Each get(AttributeRead) call returns the same decoded value object for a read; the
value is not copied. Treat a mutable value as shared, or copy it before changing it.
AttributeValues values = client.getAttributes(
"order-42",
orderFlow.orderStatus,
orderFlow.notes.instance("n1"));
String status = values.get(orderFlow.orderStatus).orElse("new");
Optional<Note> note = values.get(orderFlow.notes.instance("n1"));
-
Method Summary
Modifier and TypeMethodDescription<T> Optional<T> get(AttributeRead<T> read) Returns the decoded value of one read from the call that produced these values.
-
Method Details
-
get
Returns the decoded value of one read from the call that produced these values.The read must have been part of the
getAttributescall. A read that was not part of the call raisesIllegalArgumentExceptionrather than returningOptional.empty(), so a typo or a wrong definition object is not mistaken for an unset value. This includes anotherAttributeobject with the same name, and anAttributeMapInstanceof another AttributeMap object or another instance key.Repeated calls for the same read return the same decoded value object. The value is not copied, so changes to a mutable value are visible to every caller that shares these values.
AttributeValues values = client.getAttributes("order-42", orderFlow.orderStatus); if (!values.get(orderFlow.orderStatus).isPresent()) { log.info("order-42 has no status yet"); }- Type Parameters:
T- the Java value type of the read- Parameters:
read- theAttributeorAttributeMapInstancepassed togetAttributes, or an equalAttributeMapInstance- Returns:
- the decoded value, or
Optional.empty()when the Attribute or AttributeMap instance is not set or its stored value decodes tonull - Throws:
NullPointerException- ifreadisnullIllegalArgumentException- ifreadwas not part of the call, or is not anAttributeorAttributeMapInstance; the message names the physical key and the Flow ID of the call
-