Package org.appng.api.support
Class SelectionBuilder<T>
- java.lang.Object
-
- org.appng.api.support.OptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
-
- org.appng.api.support.SelectionBuilder<T>
-
- Type Parameters:
T
- the type to createOption
s from
public class SelectionBuilder<T> extends OptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
A builder forSelection
s, providing a fluent API.
Example:Selection persons = new SelectionBuilder
("persons").title("persons").options(Arrays.asList(a, b, c)) .select(b).disable(c).type(SelectionType.SELECT_MULTIPLE).build();
-
-
Constructor Summary
Constructors Constructor Description SelectionBuilder(String id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SelectionBuilder<T>
addGroup(OptionGroup group)
Adds aOptionGroup
to the selectionorg.appng.api.support.SelectionBuilder.Selection
build()
Creates the options and adds the to the ownerSelectionBuilder<T>
defaultOption(String name, String value)
Adds an option at the very first positionSelectionBuilder<T>
disable(Collection<T> disabled)
Disables a single element, i.e.SelectionBuilder<T>
disable(T disabled)
Disables some elements, i.e.SelectionBuilder<T>
hitCounter(OptionOwner.HitCounter<T> counter)
Sets aOptionOwner.HitCounter
SelectionBuilder<T>
name(NameProvider<T> nameProvider)
Sets theNameProvider
to use when setting an option's nameSelectionBuilder<T>
options(Iterable<T> values)
Sets the elements to build options fromSelectionBuilder<T>
select(Collection<T> selected)
Selects some elements, i.e.SelectionBuilder<T>
select(T selected)
Selects a single elements, i.e.SelectionBuilder<T>
selector(OptionOwner.Selector selector)
Sets theOptionOwner.Selector
to use when selecting options.SelectionBuilder<T>
title(String title)
Sets the title for the selectionSelectionBuilder<T>
tooltip(String tooltip)
Sets the tooltip for the selectionSelectionBuilder<T>
type(SelectionType type)
Sets theSelectionType
for the selection-
Methods inherited from class org.appng.api.support.OptionsBuilder
setOwner
-
-
-
-
Constructor Detail
-
SelectionBuilder
public SelectionBuilder(String id)
-
-
Method Detail
-
title
public SelectionBuilder<T> title(String title)
Sets the title for the selection- Parameters:
title
- the title- Returns:
- this builder
-
tooltip
public SelectionBuilder<T> tooltip(String tooltip)
Sets the tooltip for the selection- Parameters:
tooltip
- the tooltip- Returns:
- this builder
-
type
public SelectionBuilder<T> type(SelectionType type)
Sets theSelectionType
for the selection- Parameters:
type
- the type- Returns:
- this builder
-
addGroup
public SelectionBuilder<T> addGroup(OptionGroup group)
Adds aOptionGroup
to the selection- Parameters:
group
- the group- Returns:
- this builder
-
options
public SelectionBuilder<T> options(Iterable<T> values)
Description copied from class:OptionsBuilder
Sets the elements to build options from- Overrides:
options
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
values
- the elements- Returns:
- this builder
-
name
public SelectionBuilder<T> name(NameProvider<T> nameProvider)
Description copied from class:OptionsBuilder
Sets theNameProvider
to use when setting an option's name- Overrides:
name
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
nameProvider
- the provider- Returns:
- this builder
-
selector
public SelectionBuilder<T> selector(OptionOwner.Selector selector)
Description copied from class:OptionsBuilder
Sets theOptionOwner.Selector
to use when selecting options.- Overrides:
selector
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
selector
- the selector- Returns:
- this builder
- See Also:
OptionsBuilder.select(Object)
,OptionsBuilder.select(Collection)
-
select
public SelectionBuilder<T> select(Collection<T> selected)
Description copied from class:OptionsBuilder
Selects some elements, i.e. the created options will be selected.- Overrides:
select
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
selected
- the selected elements- Returns:
- this builder
- See Also:
OptionsBuilder.selector
,OptionsBuilder.select(Object)
-
select
public SelectionBuilder<T> select(T selected)
Description copied from class:OptionsBuilder
Selects a single elements, i.e. the created option will be selected.- Overrides:
select
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
selected
- the selected element- Returns:
- this builder
- See Also:
OptionsBuilder.selector
,OptionsBuilder.select(Collection)
-
disable
public SelectionBuilder<T> disable(Collection<T> disabled)
Description copied from class:OptionsBuilder
Disables a single element, i.e. the created option will be disabled- Overrides:
disable
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
disabled
- the disabled element- Returns:
- this builder
- See Also:
OptionsBuilder.disable(Object)
-
disable
public SelectionBuilder<T> disable(T disabled)
Description copied from class:OptionsBuilder
Disables some elements, i.e. the created options will be disabled- Overrides:
disable
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
disabled
- the disabled elements- Returns:
- this builder
- See Also:
OptionsBuilder.disable(Collection)
-
defaultOption
public SelectionBuilder<T> defaultOption(String name, String value)
Description copied from class:OptionsBuilder
Adds an option at the very first position- Overrides:
defaultOption
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
name
- the name for the option to be addedvalue
- the value for the option to be added- Returns:
- this builder
-
hitCounter
public SelectionBuilder<T> hitCounter(OptionOwner.HitCounter<T> counter)
Description copied from class:OptionsBuilder
Sets aOptionOwner.HitCounter
- Overrides:
hitCounter
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Parameters:
counter
- the counter- Returns:
- this builder
-
build
public org.appng.api.support.SelectionBuilder.Selection build()
Description copied from class:OptionsBuilder
Creates the options and adds the to the owner- Overrides:
build
in classOptionsBuilder<T,org.appng.api.support.SelectionBuilder.Selection>
- Returns:
- the owner the options
-
-