Package org.apache.empire.commons
Class Options
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<OptionEntry>,Collection<OptionEntry>,Set<OptionEntry>
This class represents a list of possible values that are valid for a particular field.
Additionally the class provides a text string describing the value for display purposes.
The class is implemented as a set of OptionEntry objects where the entry value is used as the key for the set and thus must be unique.
Additionally the class provides a text string describing the value for display purposes.
The class is implemented as a set of OptionEntry objects where the entry value is used as the key for the set and thus must be unique.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumInsertPos enumstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ArrayList<OptionEntry>protected Options.OptionGroupResolver -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal OptionsAdds or updates an option Same as set() but allows Option buildingfinal OptionsAdds or updates an option Same as set() but allows Option buildingbooleanadd(OptionEntry option) booleanaddAll(Collection<? extends OptionEntry> source) voidAdds all these options to the xml elementvoidAppends an option Useful for fast loading when it is certain that there are no duplicates WARNING: Does not check if the entry already existsvoidappend(OptionEntry option) Appends an option Useful for fast loading when it is certain that there are no duplicates WARNING: Does not check if the entry already existsvoidclear()clone()booleanbooleanChecks if the Option list contains an empty valueprotected OptionEntrycreateOptionEntry(Object value, String text, boolean active) protected intfindInsertPos(String text) Returns the subset of active optionsintReturns the number of active elementsgetEntryAt(int i) Gets the entry at index iprotected intReturns the function that determines the group to which an option entry belongs.getTextAt(int i) Gets the text of the entry at index igetValueAt(int i) Gets the value of the entry at index iReturns all values as a setgetValues(boolean activeOnly) Returns all values as a setbooleansame as contains(), but IDE may not issue warningbooleanbooleanisEmpty()iterator()map()Returns an immutable Map for the optionsReturns an immutable Map for the optionsbooleanfinal voidSets or adds Adds an option at the bottomvoidSets or adds Adds an option at the bottomvoidset(Object value, String text, Boolean active, Options.InsertPos pos) Sets or Adds an option at a certain positionfinal voidset(Object value, String text, Options.InsertPos pos) Sets or Adds an option at a certain positionvoidsetOptionGroupResolver(Options.OptionGroupResolver optionGroupResolver) Sets a function that determines the group to which an option entry belongs.intsize()Object[]toArray()toString()Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArrayMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
containsAll, retainAll, spliterator, toArray
-
Field Details
-
list
-
optionGroupResolver
-
-
Constructor Details
-
Options
public Options() -
Options
public Options(int initialCapacity) -
Options
-
Options
-
Options
-
-
Method Details
-
addAll
- Specified by:
addAllin interfaceCollection<OptionEntry>- Specified by:
addAllin interfaceSet<OptionEntry>- Overrides:
addAllin classAbstractCollection<OptionEntry>
-
clone
-
getOptionGroupResolver
Returns the function that determines the group to which an option entry belongs.- Returns:
- the group resolver function or null
-
setOptionGroupResolver
Sets a function that determines the group to which an option entry belongs. e.g.: options.setOptionGroupResolver((oe) -> ((MyEnum)oe.getValue()).getCategory());- Parameters:
optionGroupResolver- the group resolver function
-
getIndex
-
createOptionEntry
-
getEntry
-
get
-
isActive
-
getEntryAt
Gets the entry at index i- Parameters:
i- the index- Returns:
- the OptionEntry or null
-
getValueAt
Gets the value of the entry at index i- Parameters:
i- the index- Returns:
- the value or
nullif not found
-
getTextAt
Gets the text of the entry at index i- Parameters:
i- the index- Returns:
- the text or an empty String if not found
-
getValues
Returns all values as a set- Parameters:
activeOnly- flag whether to return the active items only- Returns:
- the value set
-
getValues
Returns all values as a set- Returns:
- the value set
-
getActiveCount
public int getActiveCount()Returns the number of active elements- Returns:
- the number of active elements
-
getActive
Returns the subset of active options- Returns:
- the active options
-
set
Sets or Adds an option at a certain position- Parameters:
value- the value objecttext- the textactive- flag if element is active (selectable)pos- the position, seeOptions.InsertPos
-
set
Sets or Adds an option at a certain position- Parameters:
value- the value objecttext- the textpos- the position, seeOptions.InsertPos
-
set
Sets or adds Adds an option at the bottom- Parameters:
value- the value objecttext- the textactive- flag whether or not the option is active
-
set
Sets or adds Adds an option at the bottom- Parameters:
value- the value objecttext- the text
-
add
Adds or updates an option Same as set() but allows Option building- Parameters:
value- the valuetext- the text for this valueactive- flag if element is active (selectable)- Returns:
- returns self (this)
-
add
Adds or updates an option Same as set() but allows Option building- Parameters:
value- the valuetext- the text for this value- Returns:
- returns self (this)
-
add
- Specified by:
addin interfaceCollection<OptionEntry>- Specified by:
addin interfaceSet<OptionEntry>- Overrides:
addin classAbstractCollection<OptionEntry>
-
append
Appends an option Useful for fast loading when it is certain that there are no duplicates WARNING: Does not check if the entry already exists- Parameters:
option- the option to append
-
append
Appends an option Useful for fast loading when it is certain that there are no duplicates WARNING: Does not check if the entry already exists- Parameters:
value- the value objecttext- the textactive- the flag whether or not this item is active
-
clear
public void clear()- Specified by:
clearin interfaceCollection<OptionEntry>- Specified by:
clearin interfaceSet<OptionEntry>- Overrides:
clearin classAbstractCollection<OptionEntry>
-
contains
- Specified by:
containsin interfaceCollection<OptionEntry>- Specified by:
containsin interfaceSet<OptionEntry>- Overrides:
containsin classAbstractCollection<OptionEntry>
-
containsNull
public boolean containsNull()Checks if the Option list contains an empty value- Returns:
- true if it contains an empty value or false otherwise
-
has
same as contains(), but IDE may not issue warning- Parameters:
value- the value to check- Returns:
- true if it exists in the options list
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<OptionEntry>- Specified by:
isEmptyin interfaceSet<OptionEntry>- Overrides:
isEmptyin classAbstractCollection<OptionEntry>
-
iterator
- Specified by:
iteratorin interfaceCollection<OptionEntry>- Specified by:
iteratorin interfaceIterable<OptionEntry>- Specified by:
iteratorin interfaceSet<OptionEntry>- Specified by:
iteratorin classAbstractCollection<OptionEntry>
-
remove
- Specified by:
removein interfaceCollection<OptionEntry>- Specified by:
removein interfaceSet<OptionEntry>- Overrides:
removein classAbstractCollection<OptionEntry>
-
size
public int size()- Specified by:
sizein interfaceCollection<OptionEntry>- Specified by:
sizein interfaceSet<OptionEntry>- Specified by:
sizein classAbstractCollection<OptionEntry>
-
toArray
- Specified by:
toArrayin interfaceCollection<OptionEntry>- Specified by:
toArrayin interfaceSet<OptionEntry>- Overrides:
toArrayin classAbstractCollection<OptionEntry>
-
map
Returns an immutable Map for the options- Returns:
- the map of options
-
map
Returns an immutable Map for the options- Type Parameters:
T- the type of the map- Parameters:
type- the map type- Returns:
- the map of options
-
toString
- Overrides:
toStringin classAbstractCollection<OptionEntry>
-
addXml
Adds all these options to the xml element- Parameters:
element- the element to add the option tags todataType- the dataType of the element
-
findInsertPos
-