E - the option enum typepublic class DefaultOptionSet<E extends Enum<E> & Option> extends Object implements OptionSet<E>, Iterable<E>, Cloneable
EnumSet.| Constructor and Description |
|---|
DefaultOptionSet(Class<E> optionType)
Constructor for an empty option set with no active options.
|
DefaultOptionSet(E option)
Constructor for option set initialized with a single option.
|
DefaultOptionSet(E first,
E... rest)
Constructor for option set initialized with at least one active options.
|
| Modifier and Type | Method and Description |
|---|---|
EnumSet<E> |
asSet()
Returns the underlying backing
EnumSet. |
DefaultOptionSet<E> |
clone() |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty()
Returns true if no option is set.
|
boolean |
isSet(E option)
Returns true if the specified
option is set and false otherwise |
Iterator<E> |
iterator()
Returns an iterator over all set options in this
OptionSet. |
Class<E> |
optionType()
Returns the option type class, usually an enum.
|
void |
set(E option)
Sets the specified
option. |
void |
setAll(Collection<? extends E> options)
Sets all specified
options. |
void |
setAll(E... options)
Sets all specified
options. |
void |
setAll(OptionSet<E> optionSet)
Sets all the options contained in the specified
optionSet. |
void |
setUseAcronymFor(E option,
boolean useAcronym)
|
void |
setUseAcronymForAll(boolean useAcronym)
|
int |
size()
Returns the number of set options in this
OptionSet |
String |
toString() |
static <O extends Option> |
toString(OptionSet<O> optionSet) |
boolean |
useAcronymFor(E option)
Returns true if the
acronym should be used in
for the specified option string representations. |
finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic DefaultOptionSet(E option)
option - the option to be setpublic DefaultOptionSet(E first, E... rest)
first - the first option to be setrest - the remaining options to be setpublic DefaultOptionSet(Class<E> optionType)
optionType - the option type classpublic Class<E> optionType()
OptionSetpublic void setAll(E... options)
options.options - the options to setpublic void setAll(Collection<? extends E> options)
options.options - the options to setpublic void setAll(OptionSet<E> optionSet)
optionSet.
Note that also the OptionSet.useAcronymFor(Option) flags are also
inherited from the specified optionSet.
optionSet - the optionSet with options to be set in this OptionSetpublic boolean isSet(E option)
OptionSetoption is set and false otherwisepublic int size()
OptionSetpublic boolean isEmpty()
public EnumSet<E> asSet()
EnumSet. Changing the returned set
will also alter this OptionSet and vice versa.public Iterator<E> iterator()
OptionSet.
Removing an option from thepublic DefaultOptionSet<E> clone()
public boolean useAcronymFor(E option)
OptionSetacronym should be used in
for the specified option string representations. Note that some
implementations may return the same value for all options.public void setUseAcronymForAll(boolean useAcronym)
acronym instead of the long option
name for all options.useAcronym - new flag value to set, true if the option acronym should be
used for all optionssetUseAcronymFor(Enum, boolean)public void setUseAcronymFor(E option, boolean useAcronym)
acronym instead of the long option
name for the specified option.option - the option for which this flag is setuseAcronym - new flag value to set, true if the option acronym should be
used for the specified optionsetUseAcronymForAll(boolean)Copyright © 2025. All rights reserved.