class OptionableUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <O extends Option,E extends Enum<E> & Optionable<O>> |
findEnumByOption(Class<E> enumClass,
O option)
Finds an enum constant by a given option through the enum/option
association given by the
Optionable interface implemented by the
enum. |
static <O extends Option,E extends Enum<E> & Optionable<O>> |
findFirstEnumByOptionInSet(Class<E> enumClass,
OptionSet<O> optionSet,
E defaultEnum)
Finds an enum constant by a comparing the options associated with the
enum constant with the options in the specified set.
|
public static <O extends Option,E extends Enum<E> & Optionable<O>> E findEnumByOption(Class<E> enumClass, O option)
Optionable
interface implemented by the
enum. If no enum constant is found for the given option, null is
returned.O
- the option typeE
- the enum typeenumClass
- the enum classoption
- the option to look forpublic static <O extends Option,E extends Enum<E> & Optionable<O>> E findFirstEnumByOptionInSet(Class<E> enumClass, OptionSet<O> optionSet, E defaultEnum)
Optionable
interface implemented by
the enum.
If no enum constant is found with an associated option in the given set,
the specified defaultEnum
value is returned. If multiple enum
constants have an associated option in the given set, the first enum with
such an option is returned.
O
- the option typeE
- the enum typeenumClass
- the enum classoptionSet
- the option set to lookup associated optionsdefaultEnum
- the default enum value returned if no enum has an associated
option in the given option setCopyright © 2024. All rights reserved.