This class provides advanced methods on enums. It is ideally used with
using EnumTools
and then acts as an
extension to the
enum
types.
If the first argument to any of the methods is null
, the result is
unspecified.
Static methods
staticinlinecreateAll<T>(e:Enum<T>):Array<T>
Returns a list of all constructors of enum e
that require no
arguments.
This may return the empty Array []
if all constructors of e
require
arguments.
Otherwise an instance of e
constructed through each of its non-
argument constructors is returned, in the order of the constructor
declaration.
If e
is null
, the result is unspecified.
staticinlinecreateByIndex<T>(e:Enum<T>, index:Int, ?params:Array<Dynamic>):T
Creates an instance of enum e
by calling its constructor number
index
with arguments params
.
The constructor indices are preserved from Haxe syntax, so the first declared is index 0, the next index 1 etc.
If e
or index
is null
, or if enum e
has no constructor
corresponding to index index
, or if the number of elements in params
does not match the expected number of constructor arguments, or if any
argument has an invalid type, the result is unspecified.
staticinlinecreateByName<T>(e:Enum<T>, constr:String, ?params:Array<Dynamic>):T
Creates an instance of enum e
by calling its constructor constr
with
arguments params
.
If e
or constr
is null
, or if enum e
has no constructor named
constr
, or if the number of elements in params
does not match the
expected number of constructor arguments, or if any argument has an
invalid type, the result is unspecified.
staticinlinegetConstructors<T>(e:Enum<T>):Array<String>
Returns a list of the names of all constructors of enum e
.
The order of the constructor names in the returned Array is preserved from the original syntax.
If c
is null
, the result is unspecified.
staticinlinegetName<T>(e:Enum<T>):String
Returns the name of enum e
, including its path.
If e
is inside a package, the package structure is returned dot-
separated, with another dot separating the enum name:
pack1.pack2.(...).packN.EnumName
If e
is a sub-type of a Haxe module, that module is not part of the
package structure.
If e
has no package, the enum name is returned.
If e
is null
, the result is unspecified.
The enum name does not include any type parameters.