Class ValueOptions<I>
java.lang.Object
com.vaadin.flow.component.ai.form.ValueOptions<I>
- Type Parameters:
I- the per-label item type the controller's converter must produce. For a single-value fieldIis the field's value type; for a multi-select fieldIis the per-element type. The controller'svalueOptions(...)overload set enforces at compile time that a converter is supplied for everyIother thanString
Per-field options registration passed to
controller.valueOptions(...). Carries the field together with either a fixed
label list or a query callback. The label-to-value converter is supplied
separately to the controller at registration time, not on this object — see
valueOptions(config, toValue).
Two forField factories cover all field shapes:
forField(HasValue)— single-value fields. The type parameterVof the field flows through.forField(MultiSelect)— multi-select fields. Picked by the compiler whenever the reference is statically typed asMultiSelect. The per-element type flows through; the controller aggregates resolved per-label items into aLinkedHashSetbeforeHasValue.setValue(V).
options(Collection) (fixed labels) and
options(BiFunction) (queryable labels) must be set; calling one
clears the other so the last setter wins.- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> ValueOptions<V> Starts a single-value options registration.static <T,C extends Component>
ValueOptions<T> forField(MultiSelect<C, T> field) Starts a multi-select options registration.options(Collection<String> options) Sets a fixed label list.Sets a queryable label callback the LLM drives viaquery_field_options.
-
Method Details
-
forField
Starts a single-value options registration. The field's value typeVflows through; for aVother thanString, the controller's two-argumentFormAIController.valueOptions(ValueOptions, Function)overload must be used to supply a converter — that is a compile-time requirement, not a runtime check.- Type Parameters:
V- the field's value type- Parameters:
field- the single-value field whose options the LLM may pick from, notnull- Returns:
- a fresh registration ready to receive
options(...)
-
forField
Starts a multi-select options registration. Picked by the compiler overforField(HasValue)whenever the reference is statically typed asMultiSelect. The per-element type flows through; for any type other thanString, the controller's two-argumentFormAIController.valueOptions(ValueOptions, Function)overload must be used. The controller aggregates resolved per-label items into aLinkedHashSetbeforeHasValue.setValue(V).- Type Parameters:
T- the per-element typeC- the field's source-component type- Parameters:
field- the multi-select field whose options the LLM may pick from, notnull- Returns:
- a fresh registration ready to receive
options(...)
-
options
Sets a fixed label list. A defensive copy is taken so later mutations of the caller's collection have no effect. Mutually exclusive withoptions(BiFunction)— calling either clears the other.- Parameters:
options- the labels the LLM may pick from, notnulland not empty- Returns:
- this registration, for chaining
- Throws:
IllegalArgumentException- ifoptionsis empty — registering an empty fixed list leaves the field un-fillable and is always a developer mistake
-
options
Sets a queryable label callback the LLM drives viaquery_field_options. Mutually exclusive withoptions(Collection)— calling either clears the other.- Parameters:
query- the filter callback returning labels for the LLM, notnull- Returns:
- this registration, for chaining
-