public final class JCEnum extends Object
[Flags] enums.
A JCEnum carries the fully qualified CLR enum type name, one or more selected
values (for [Flags] enums), and the complete set of valid values for the type.
Instances are obtained via JCOBridge.GetEnum(String) and must not be constructed
directly.
For plain (non-Flags) enums, a JCEnum holds a single value and fromValue(java.lang.String)
is the primary factory. For [Flags] enums, multiple values can be combined using
add(JCEnum) (logical OR) and removed with remove(JCEnum) (logical XOR).
Membership tests are available via is(JCEnum) (exact match) and
has(JCEnum) (subset check).
All operations that combine two JCEnum instances enforce type safety: mixing
values from different CLR enum types throws JCException.
See also: JCOReflector for usage examples.
| Modifier and Type | Method and Description |
|---|---|
JCEnum |
add(JCEnum value)
Returns a new
JCEnum that is the logical OR (union) of this instance
and value. |
JCEnum |
fromValue(String val)
Returns a new
JCEnum instance selecting the given single value. |
JCEnum |
fromValues(String... values)
Returns a new
JCEnum instance selecting the given values. |
String[] |
getAllValues()
Returns all valid value names for this CLR enum type.
|
String |
getTypeName()
Returns the fully qualified CLR enum type name.
|
String |
getValue()
Returns the currently selected value(s) as a comma-separated string.
|
String[] |
getValues()
Returns the currently selected value names as an array.
|
boolean |
has(JCEnum value)
Returns
true if this instance contains at least one of the values
in value (subset / flag-present check). |
boolean |
is(JCEnum value)
Returns
true if this instance selects exactly the same set of values
as value (exact equality, not subset). |
JCEnum |
remove(JCEnum value)
Returns a new
JCEnum that is the logical XOR (difference) of this instance
and value, removing the flags present in value from this instance. |
String |
toString()
Returns a human-readable string in the form
"TypeName: value1, value2, ...". |
public JCEnum fromValue(String val) throws JCException
JCEnum instance selecting the given single value.
Equivalent to fromValues(String...) with a single argument.val - the string name of the enum value to select.JCEnum with the selected value.JCException - if val is not a valid value for this enum type.public JCEnum fromValues(String... values) throws JCException
JCEnum instance selecting the given values.
Use this method for [Flags] enums to combine multiple named flags.values - the string names of the enum values to select.JCEnum with the selected values.JCException - if any of the given values is not a member of this enum type.public String toString()
"TypeName: value1, value2, ...".public String getTypeName()
"System.IO.FileMode".public String getValue()
[Flags] enums
it is the comma-separated list of active flag names.public String[] getValues()
[Flags] enums
it contains all active flag names.public String[] getAllValues()
public JCEnum add(JCEnum value) throws JCException
JCEnum that is the logical OR (union) of this instance
and value. Intended for [Flags] enums. Duplicate values are
deduplicated in the result.value - the flags to add.JCEnum containing all flags from both operands.JCException - if value belongs to a different CLR enum type.public JCEnum remove(JCEnum value) throws JCException
JCEnum that is the logical XOR (difference) of this instance
and value, removing the flags present in value from this instance.
Intended for [Flags] enums.value - the flags to remove.JCEnum with the specified flags removed.JCException - if value belongs to a different CLR enum type.public boolean is(JCEnum value) throws JCException
true if this instance selects exactly the same set of values
as value (exact equality, not subset).value - the enum instance to compare with.true if both instances select the same values.JCException - if value belongs to a different CLR enum type.public boolean has(JCEnum value) throws JCException
true if this instance contains at least one of the values
in value (subset / flag-present check). Intended for [Flags] enums.value - the flags to test for presence.true if any flag in value is set in this instance.JCException - if value belongs to a different CLR enum type.