Package org.appng.api.support
Class OptionsBuilder<T,R extends OptionOwner>
- java.lang.Object
-
- org.appng.api.support.OptionsBuilder<T,R>
-
- Type Parameters:
T
- the type to createOption
s fromR
- the owner of the options
- Direct Known Subclasses:
SelectionBuilder
public class OptionsBuilder<T,R extends OptionOwner> extends Object
A builder forOption
s, providing a fluent API.- Author:
- Matthias Müller
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OptionsBuilder()
OptionsBuilder(R owner)
Create a new builder, using the given owner.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description R
build()
Creates the options and adds the to the ownerOptionsBuilder<T,R>
defaultOption(String name, String value)
Adds an option at the very first positionOptionsBuilder<T,R>
disable(Collection<T> disabled)
Disables a single element, i.e.OptionsBuilder<T,R>
disable(T disabled)
Disables some elements, i.e.OptionsBuilder<T,R>
hitCounter(OptionOwner.HitCounter<T> counter)
Sets aOptionOwner.HitCounter
OptionsBuilder<T,R>
name(NameProvider<T> nameProvider)
Sets theNameProvider
to use when setting an option's nameOptionsBuilder<T,R>
options(Iterable<T> elements)
Sets the elements to build options fromOptionsBuilder<T,R>
select(Collection<T> selected)
Selects some elements, i.e.OptionsBuilder<T,R>
select(T selected)
Selects a single elements, i.e.OptionsBuilder<T,R>
selector(OptionOwner.Selector selector)
Sets theOptionOwner.Selector
to use when selecting options.protected void
setOwner(R owner)
Sets the owner for this builder
-
-
-
Constructor Detail
-
OptionsBuilder
public OptionsBuilder(R owner)
Create a new builder, using the given owner.- Parameters:
owner
- the owner of the options
-
OptionsBuilder
protected OptionsBuilder()
-
-
Method Detail
-
setOwner
protected void setOwner(R owner)
Sets the owner for this builder- Parameters:
owner
- the owner
-
options
public OptionsBuilder<T,R> options(Iterable<T> elements)
Sets the elements to build options from- Parameters:
elements
- the elements- Returns:
- this builder
-
name
public OptionsBuilder<T,R> name(NameProvider<T> nameProvider)
Sets theNameProvider
to use when setting an option's name- Parameters:
nameProvider
- the provider- Returns:
- this builder
-
selector
public OptionsBuilder<T,R> selector(OptionOwner.Selector selector)
Sets theOptionOwner.Selector
to use when selecting options.- Parameters:
selector
- the selector- Returns:
- this builder
- See Also:
select(Object)
,select(Collection)
-
select
public OptionsBuilder<T,R> select(Collection<T> selected)
Selects some elements, i.e. the created options will be selected.- Parameters:
selected
- the selected elements- Returns:
- this builder
- See Also:
selector
,select(Object)
-
select
public OptionsBuilder<T,R> select(T selected)
Selects a single elements, i.e. the created option will be selected.- Parameters:
selected
- the selected element- Returns:
- this builder
- See Also:
selector
,select(Collection)
-
disable
public OptionsBuilder<T,R> disable(Collection<T> disabled)
Disables a single element, i.e. the created option will be disabled- Parameters:
disabled
- the disabled element- Returns:
- this builder
- See Also:
disable(Object)
-
disable
public OptionsBuilder<T,R> disable(T disabled)
Disables some elements, i.e. the created options will be disabled- Parameters:
disabled
- the disabled elements- Returns:
- this builder
- See Also:
disable(Collection)
-
defaultOption
public OptionsBuilder<T,R> defaultOption(String name, String value)
Adds an option at the very first position- Parameters:
name
- the name for the option to be addedvalue
- the value for the option to be added- Returns:
- this builder
-
hitCounter
public OptionsBuilder<T,R> hitCounter(OptionOwner.HitCounter<T> counter)
Sets aOptionOwner.HitCounter
- Parameters:
counter
- the counter- Returns:
- this builder
-
build
public R build()
Creates the options and adds the to the owner- Returns:
- the owner the options
-
-