Package org.appng.api.support
Class SelectionFactory
- java.lang.Object
-
- org.appng.api.support.SelectionFactory
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SelectionFactory.Selection
-
Constructor Summary
Constructors Constructor Description SelectionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
countHits(Iterable<Option> options, OptionOwner.HitCounter<String> counter)
Counts and sets the hits for the options based on their value.void
countHits(OptionOwner optionOwner, OptionOwner.HitCounter<String> counter)
Counts and sets the hits for the owner's options based on their value.<E extends Enum<E>>
TfromEnum(String id, String titleId, E[] allElements, E selectedElement)
Builds and returns a newOptionOwner
using the givenEnum
elements.<E extends Enum<E>>
TfromEnum(String id, String titleId, E[] allElements, E selectedElement, NameProvider<E> nameProvider)
Builds and returns a newOptionOwner
using the givenEnum
elements.<E extends Enum<E>>
TfromEnum(String id, String titleId, E[] allElements, Collection<E> selectedElements)
Builds and returns a newOptionOwner
using the givenEnum
elements.<E extends Enum<E>>
TfromEnum(String id, String titleId, E[] allElements, Collection<E> selectedElements, NameProvider<E> nameProvider)
Builds and returns a newOptionOwner
using the givenEnum
elements.<I extends Identifiable<?>>
TfromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, I selectedElement)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements.<I extends Identifiable<?>>
TfromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, I selectedElement, NameProvider<I> nameProvider)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements.<I extends Identifiable<?>>
TfromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, Collection<? extends I> selectedElements)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements.<I extends Identifiable<?>>
TfromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, Collection<? extends I> selectedElements, NameProvider<I> nameProvider)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements.<I extends Identifiable<?>>
TfromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, OptionOwner.Selector selector)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements.<I extends Identifiable<?>>
TfromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, OptionOwner.Selector selector, NameProvider<I> nameProvider)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements.<N extends Named<?>>
TfromNamed(String id, String titleId, Iterable<? extends N> allElements, Collection<? extends N> selectedElements)
Builds and returns a newOptionOwner
using the givenNamed
elements.<N extends Named<?>>
TfromNamed(String id, String titleId, Iterable<? extends N> allElements, Collection<? extends N> selectedElements, NameProvider<N> nameProvider)
Builds and returns a newOptionOwner
using the givenNamed
elements.<N extends Named<?>>
TfromNamed(String id, String titleId, Iterable<? extends N> allElements, N selectedElement)
Builds and returns a newOptionOwner
using the givenNamed
elements.<N extends Named<?>>
TfromNamed(String id, String titleId, Iterable<? extends N> allElements, N selectedElement, NameProvider<N> nameProvider)
Builds and returns a newOptionOwner
using the givenNamed
elements.<N extends Named<?>>
TfromNamed(String id, String titleId, Iterable<? extends N> allElements, OptionOwner.Selector selector)
Builds and returns a newOptionOwner
using the givenNamed
elements.<N extends Named<?>>
TfromNamed(String id, String titleId, Iterable<? extends N> allElements, OptionOwner.Selector selector, NameProvider<N> nameProvider)
Builds and returns a newOptionOwner
using the givenNamed
elements.<S> T
fromObjects(String id, String titleId, S[] allElements, NameProvider<S> nameProvider, S... selectedElements)
Builds and returns a newOptionOwner
using the givenObject
s.<S> T
fromObjects(String id, String titleId, S[] allElements, OptionOwner.Selector selector)
Builds and returns a newOptionOwner
using the givenObject
s.<S> T
fromObjects(String id, String titleId, S[] allElements, OptionOwner.Selector selector, NameProvider<S> nameProvider)
Builds and returns a newOptionOwner
using the givenObject
s.<S> T
fromObjects(String id, String titleId, S[] allElements, S... selectedElements)
Builds and returns a newOptionOwner
using the givenObject
s.SelectionFactory.Selection
getDateSelection(String id, String title, String value, String dateFormat)
SelectionFactory.Selection
getDateSelection(String id, String title, Date value, org.apache.commons.lang3.time.FastDateFormat dateFormat)
protected SelectionFactory.Selection
getOwner(String id, String title)
SelectionFactory.Selection
getSimpleSelection(String id, String title, String value, SelectionType type)
SelectionFactory.Selection
getTextSelection(String id, String title, String value)
-
-
-
Method Detail
-
getOwner
protected SelectionFactory.Selection getOwner(String id, String title)
-
getTextSelection
public SelectionFactory.Selection getTextSelection(String id, String title, String value)
Creates aSelectionFactory.Selection
of typeSelectionType.TEXT
with only oneOption
. This option uses the given id as its name and the given value.- Parameters:
id
- the id for theSelectionFactory.Selection
and also the name of the singleOption
title
- the title for theSection
value
- theOption
's value- Returns:
- a
SelectionFactory.Selection
of the given type with oneOption
-
getDateSelection
public SelectionFactory.Selection getDateSelection(String id, String title, String value, String dateFormat)
Creates aSelectionFactory.Selection
of typeSelectionType.DATE
with only oneOption
. This option uses the given id as its name and the given value.- Parameters:
id
- the id for theSelectionFactory.Selection
and also the name of the singleOption
title
- the title for theSection
value
- theOption
's valuedateFormat
- the date format pattern to be used- Returns:
- a
SelectionFactory.Selection
of the given type with oneOption
-
getDateSelection
public SelectionFactory.Selection getDateSelection(String id, String title, Date value, org.apache.commons.lang3.time.FastDateFormat dateFormat)
Creates aSelectionFactory.Selection
of typeSelectionType.DATE
with only oneOption
. This option uses the given id as its name and the given value which is being formatted.FastDateFormat.getPattern()
is used forSelection.setFormat(String)
.- Parameters:
id
- the id for theSelectionFactory.Selection
and also the name of the singleOption
title
- the title for theSection
value
- theOption
's value as aDate
dateFormat
-- Returns:
- a
SelectionFactory.Selection
of typeSelectionType.DATE
with oneOption
-
getSimpleSelection
public SelectionFactory.Selection getSimpleSelection(String id, String title, String value, SelectionType type)
Creates aSelectionFactory.Selection
of the givenSelectionType
with only oneOption
. This option uses the given id as its name and the given value.- Parameters:
id
- the id for theSelectionFactory.Selection
and also the name of the singleOption
title
- the title for theSection
value
- theOption
's value- Returns:
- a
SelectionFactory.Selection
of the givenSelectionType
with oneOption
-
fromNamed
public <N extends Named<?>> T fromNamed(String id, String titleId, Iterable<? extends N> allElements, Collection<? extends N> selectedElements, NameProvider<N> nameProvider)
Builds and returns a newOptionOwner
using the givenNamed
elements. For theOption
's id,Identifiable.getId()
is used. If noNameProvider
is given, {@link Named#getName()()} is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elementsnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromNamed
public <N extends Named<?>> T fromNamed(String id, String titleId, Iterable<? extends N> allElements, N selectedElement, NameProvider<N> nameProvider)
Builds and returns a newOptionOwner
using the givenNamed
elements. For theOption
's id,Identifiable.getId()
is used. If noNameProvider
is given, {@link Named#getName()()} is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElement
- the selected elementnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromNamed
public <N extends Named<?>> T fromNamed(String id, String titleId, Iterable<? extends N> allElements, Collection<? extends N> selectedElements)
Builds and returns a newOptionOwner
using the givenNamed
elements. For theOption
's id,Identifiable.getId()
is used. {@link Named#getName()()} is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elements- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromNamed
public <N extends Named<?>> T fromNamed(String id, String titleId, Iterable<? extends N> allElements, N selectedElement)
Builds and returns a newOptionOwner
using the givenNamed
elements. For theOption
's id,Identifiable.getId()
is used. {@link Named#getName()()} is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElement
- the selected element- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromNamed
public <N extends Named<?>> T fromNamed(String id, String titleId, Iterable<? extends N> allElements, OptionOwner.Selector selector)
Builds and returns a newOptionOwner
using the givenNamed
elements. For theOption
's id,Identifiable.getId()
is used. {@link Named#getName()()} is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselector
- aOptionOwner.Selector
- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromNamed
public <N extends Named<?>> T fromNamed(String id, String titleId, Iterable<? extends N> allElements, OptionOwner.Selector selector, NameProvider<N> nameProvider)
Builds and returns a newOptionOwner
using the givenNamed
elements. For theOption
's id,Identifiable.getId()
is used. If noNameProvider
is given, {@link Named#getName()()} is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselector
- aOptionOwner.Selector
nameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromIdentifiable
public <I extends Identifiable<?>> T fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, Collection<? extends I> selectedElements)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements. For theOption
's id,Identifiable.getId()
is used, for the valueObject.toString()
.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elements- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromIdentifiable
public <I extends Identifiable<?>> T fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, I selectedElement)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements. For theOption
's id,Identifiable.getId()
is used, for the valueObject.toString()
.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElement
- the selected element- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromIdentifiable
public <I extends Identifiable<?>> T fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, I selectedElement, NameProvider<I> nameProvider)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements. For theOption
's id,Identifiable.getId()
is used. If noNameProvider
is given,Object.toString()
is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElement
- the selected elementnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromIdentifiable
public <I extends Identifiable<?>> T fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, Collection<? extends I> selectedElements, NameProvider<I> nameProvider)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements. For theOption
's id,Identifiable.getId()
is used. If noNameProvider
is given,Object.toString()
is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elementsnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromIdentifiable
public <I extends Identifiable<?>> T fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, OptionOwner.Selector selector)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements. For theOption
's id,Identifiable.getId()
is used, for the valueObject.toString()
.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselector
- aOptionOwner.Selector
- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromIdentifiable
public <I extends Identifiable<?>> T fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, OptionOwner.Selector selector, NameProvider<I> nameProvider)
Builds and returns a newOptionOwner
using the givenIdentifiable
elements. For theOption
's id,Identifiable.getId()
is used. If noNameProvider
is given,Object.toString()
is used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselector
- aOptionOwner.Selector
nameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromEnum
public <E extends Enum<E>> T fromEnum(String id, String titleId, E[] allElements, Collection<E> selectedElements)
Builds and returns a newOptionOwner
using the givenEnum
elements. For both, theOption
's id and value,Enum.name()
is used.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elements- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromEnum
public <E extends Enum<E>> T fromEnum(String id, String titleId, E[] allElements, E selectedElement)
Builds and returns a newOptionOwner
using the givenEnum
elements. For both, theOption
's id and value,Enum.name()
is used.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElement
- the selected element- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromEnum
public <E extends Enum<E>> T fromEnum(String id, String titleId, E[] allElements, Collection<E> selectedElements, NameProvider<E> nameProvider)
Builds and returns a newOptionOwner
using the givenEnum
elements. For theOption
's id,Enum.name()
is used. If noNameProvider
is given,Enum.name()
is also used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elementsnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromEnum
public <E extends Enum<E>> T fromEnum(String id, String titleId, E[] allElements, E selectedElement, NameProvider<E> nameProvider)
Builds and returns a newOptionOwner
using the givenEnum
elements. For theOption
's id,Enum.name()
is used. If noNameProvider
is given,Enum.name()
is also used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElement
- the selected elementnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromObjects
public <S> T fromObjects(String id, String titleId, S[] allElements, OptionOwner.Selector selector)
Builds and returns a newOptionOwner
using the givenObject
s. For both, theOption
's id and value,Object.toString()
is used.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselector
- aOptionOwner.Selector
- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromObjects
public <S> T fromObjects(String id, String titleId, S[] allElements, OptionOwner.Selector selector, NameProvider<S> nameProvider)
Builds and returns a newOptionOwner
using the givenObject
s. For theOption
's id,Object.toString()
is used. If noNameProvider
is given,Object.toString()
is also used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselector
- aOptionOwner.Selector
nameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromObjects
public <S> T fromObjects(String id, String titleId, S[] allElements, S... selectedElements)
Builds and returns a newOptionOwner
using the givenObject
s. For both, theOption
's id and value,Object.toString()
is used.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elements- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
fromObjects
public <S> T fromObjects(String id, String titleId, S[] allElements, NameProvider<S> nameProvider, S... selectedElements)
Builds and returns a newOptionOwner
using the givenObject
s. For theOption
's id,Object.toString()
is used. If noNameProvider
is given,Object.toString()
is also used for theOption
's value.- Parameters:
id
- the id of theOptionOwner
titleId
- the title-id of theOptionOwner
(seeLabel.getId()
).allElements
- the elements to createOption
s fromselectedElements
- the selected elementsnameProvider
- aNameProvider
(optional)- Returns:
- a new
OptionOwner
(actually aSelection
or aOptionGroup
)
-
countHits
public void countHits(Iterable<Option> options, OptionOwner.HitCounter<String> counter)
Counts and sets the hits for the options based on their value.- Parameters:
options
- some optionscounter
- aOptionOwner.HitCounter
- See Also:
Option.getValue()
,Option.getHits()
-
countHits
public void countHits(OptionOwner optionOwner, OptionOwner.HitCounter<String> counter)
Counts and sets the hits for the owner's options based on their value.- Parameters:
optionOwner
- anOptionOwner
counter
- aOptionOwner.HitCounter
- See Also:
Option.getValue()
,Option.getHits()
-
-