@Retention(value=RUNTIME)
@Target(value=TYPE)
@Documented
public @interface JsEnum
The underlying type of the Closure enum can be specified via hasCustomValue()
and
declaring an instance field named "value" of the desired type.
If the JsEnum is non-native and has custom values, a constructor is required to allow specifying the values for the enum constants, as in the following example
@JsEnum(hasCustomValue=true)
enum IntJsEnum {
TEN(10),
TWENTY(20);
int value;
IntJsEnum(int value) { this.value = value; }
}
If the JsEnum is native and has custom values, the value field is still required but constructors are not needed nor allowed.
JsEnums do not support the full Java semantics:
value
,
Enum.name()
and values()
are not supported.
Enum.ordinal()
is supported only for non-native JsEnums that don't have custom
values.
The JavaScript namespace and name can be specified in a manner similar to JsTypes via namespace()
and name()
respectively.
Methods and fields declared in the JsEnum are only accessible in Java code. Only the enum constants are accessible from JavaScript code.
This annotation is only supported by J2CL.
Modifier and Type | Optional Element and Description |
---|---|
boolean |
hasCustomValue
When set to
true , this JsEnum will have a custom value defined by a field named
'value'. |
boolean |
isNative
When set to
true , this JsEnum is a native Closure enum type. |
java.lang.String |
name
Customizes the name of the type in generated JavaScript.
|
java.lang.String |
namespace
Customizes the namespace of the type in generated JavaScript.
|
public abstract java.lang.String name
public abstract java.lang.String namespace