TYPE
- is the generic type of the enum type
.CATEGORY
- is the generic type of the category
or Void
for none.public abstract class AbstractEnumDefinition<TYPE,CATEGORY> extends Object implements EnumDefinition<TYPE,CATEGORY>
EnumDefinition
for a java Enum
.Modifier and Type | Field and Description |
---|---|
private Formatter<TYPE> |
formatter |
private static long |
serialVersionUID |
Constructor and Description |
---|
AbstractEnumDefinition()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
List<TYPE> |
getEnumValues() |
Formatter<TYPE> |
getFormatter()
|
protected String |
getKey(Class<TYPE> type)
This method is called from the constructor to set the
value . |
String |
getValue()
This method returns the raw value of this datatype.
|
boolean |
isCachable() |
boolean |
isMutable() |
protected void |
setFormatter(Formatter<TYPE> formatter) |
String |
toString()
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCategory, getEnumType
private static final long serialVersionUID
protected String getKey(Class<TYPE> type)
value
. By default it returns
Class.getName()
. Override to change (e.g. to Class.getSimpleName()
).type
- is the EnumDefinition.getEnumType()
.getValue()
to use.public final Formatter<TYPE> getFormatter()
EnumDefinition
Formatter
used to format
instances of the enum as
String
for end-users. By default FormatterToString
can be used. However,
e.g. for the type Boolean
you might want to display as "yes" or "no" and might have an alternative
EnumDefinition
for Boolean
that displays as "all" or "none". Further, also I18N (see
NlsMessage
) can be addressed by this Formatter
.EnumDefinition
may be used with or without allowing a null
value. Therefore, this
Formatter
should be able to properly format null
(see
AbstractFormatter
.formatNull()
). E.g. a Boolean
option in a
search form may be optional and displayed as "any".getFormatter
in interface EnumDefinition<TYPE,CATEGORY>
Formatter
.protected void setFormatter(Formatter<TYPE> formatter)
formatter
- is the new value of getFormatter()
.public String getValue()
EnumDefinition
String
, Character
, Boolean
, any type of Number
, any type of java.time.LocalDate
, etc.).
enum type
and has to be unique for
all available enumerations
.getValue
in interface AttributeReadValue<String>
getValue
in interface EnumDefinition<TYPE,CATEGORY>
getValue
in interface SimpleDatatype<String>
public String toString()
Datatype
String
representation of this Datatype
. While the general contract of
Object.toString()
is very weak and mainly used for debugging, the contract here is very strong. The
returned String
has to be suitable for end-users and official output to any kind of sink. NlsMessage
for
this purpose and implement NlsObject
if you want to support I18N/L10N.public List<TYPE> getEnumValues()
List
of the enum values
or null
if the values are NOT
static and have to be loaded asynchronous via EnumProvider
.public boolean isMutable()
public boolean isCachable()
isCachable
in interface EnumDefinition<TYPE,CATEGORY>
true
if all EnumType
-instances of this type
can cached (default) or
false
if there are too many of them (e.g. for entities like cities of the world).Copyright © 2001–2016 mmm-Team. All rights reserved.