Class SelectOption
- java.lang.Object
-
- com.broadleafcommerce.metadata.dsl.core.extension.fields.SelectOption
-
- All Implemented Interfaces:
Copyable<SelectOption>
,Serializable
public class SelectOption extends Object implements Serializable, Copyable<SelectOption>
Represents an option within aSelectField
.- Author:
- Nick Crum (ncrum)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SelectOption.SelectOptionEnum
An enum interface used as a method for defining a finite list ofSelectOption
.
-
Constructor Summary
Constructors Constructor Description SelectOption()
SelectOption(SelectOption option)
SelectOption(String value, InternationalizedMessage label)
SelectOption(String value, String labelKey)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SelectOption
attribute(String key, Object value)
protected boolean
canEqual(Object other)
SelectOption
color(String color)
SelectOption
copy()
boolean
equals(Object o)
static List<SelectOption>
fromAllLocales()
Returns the list of all installed locales converted toSelectOption
.static List<SelectOption>
fromEnums(SelectOption.SelectOptionEnum[] optionEnums)
Factory method to generate a set ofSelectOption
from the passed enumeration.static List<SelectOption>
fromLocales(List<Locale> locales)
Returns the list of the specified locales converted toSelectOption
.static List<SelectOption>
fromTimeZones()
Returns the list of allZoneId.getAvailableZoneIds()
converted toSelectOption
.static List<SelectOption>
fromTimeZones(Set<String> zoneIds)
Returns the list of the specified time-zones converted toSelectOption
.Map<String,Object>
getAttributes()
String
getColor()
Optional color to display alongside the labelInternationalizedMessage
getLabel()
The user-friendly text that the user sees as the select optionString
getValue()
The underlying form value that the user selectsint
hashCode()
SelectOption
label(InternationalizedMessage label)
SelectOption
label(String labelKey)
SelectOption
value(String value)
-
-
-
Constructor Detail
-
SelectOption
public SelectOption()
-
SelectOption
public SelectOption(String value, InternationalizedMessage label)
-
SelectOption
public SelectOption(SelectOption option)
-
-
Method Detail
-
copy
public SelectOption copy()
- Specified by:
copy
in interfaceCopyable<SelectOption>
- Returns:
- a deep copy of this instance
-
value
public SelectOption value(String value)
-
label
public SelectOption label(InternationalizedMessage label)
-
label
public SelectOption label(String labelKey)
-
color
public SelectOption color(String color)
-
attribute
public SelectOption attribute(String key, Object value)
-
fromEnums
public static List<SelectOption> fromEnums(SelectOption.SelectOptionEnum[] optionEnums)
Factory method to generate a set ofSelectOption
from the passed enumeration.- Parameters:
optionEnums
- the enums- Returns:
- the set of options
-
fromAllLocales
public static List<SelectOption> fromAllLocales()
Returns the list of all installed locales converted toSelectOption
.- Returns:
- the list of all installed locales converted to
SelectOption
- See Also:
Locale.getAvailableLocales()
,fromLocales(List)
-
fromLocales
public static List<SelectOption> fromLocales(List<Locale> locales)
Returns the list of the specified locales converted toSelectOption
. The value is retrieved fromLocale.toLanguageTag()
. The label represents the message property e.g. "locales.en-GB=English (GB)", where "en-GB" is retrieved fromLocale.toLanguageTag()
.- Parameters:
locales
- the locales to convert- Returns:
- the list of locales converted to
SelectOption
-
fromTimeZones
public static List<SelectOption> fromTimeZones()
Returns the list of allZoneId.getAvailableZoneIds()
converted toSelectOption
.- Returns:
- the list of all
ZoneId.getAvailableZoneIds()
converted toSelectOption
-
fromTimeZones
public static List<SelectOption> fromTimeZones(Set<String> zoneIds)
Returns the list of the specified time-zones converted toSelectOption
. The value is the time-zone ID. The label represents the message property e.g. "time.zone.id.america_new_york=America/New_York".- Parameters:
zoneIds
- the list of zone IDs- Returns:
- the list of zone IDs converted to
SelectOption
-
getValue
public String getValue()
The underlying form value that the user selects
-
getLabel
public InternationalizedMessage getLabel()
The user-friendly text that the user sees as the select option
This label can be a message key for I18n concerns
-
getColor
public String getColor()
Optional color to display alongside the label
-
canEqual
protected boolean canEqual(Object other)
-
-