Using enum type

You are browsing legacy Javonet 1.5 (Java<>.NET bridge for Windows) documentation. Use the left side menu or click here to switch to latest Javonet 2.0 documentation. Javonet 2.0 allows you to use any module from JVM, CLR, Netcore, Python, Ruby, Perl, NodeJS on Windows, Linux and MacOs from any application created in Java, Clojure, Groovy, Kotlin, C#, F#, J#, VB.NET, Python, Perl, Ruby, JavaScript, TypeScript, C++ and GoLang

To use .NET enums in your Java project, javonet API provides special NEnum type. Using this class you can keep the reference of particular enum value, get/set the enum value, pass the enum value as method argument or compare enum values.
To initialize reference to .NET enum type you can use the NEnum(String enumTypeName, String enumValue) constructor. As first argument you must provide enum type name with or without namespace. When namespace is not provided Javonet will automatically lookup the enum type in all loaded assemblies, if there is only one type with provided name it will be used. In second argument selected enum value should be provided.

Assuming we have a custom any runtime with the following enum inside:

Select technology of module you want to use:

Enum usage:

I code in:

Select technology of module you want to use:

How to pass enum as method argument:

Assuming we have a custom any runtime with the following class inside:

Select technology of module you want to use:

To use enum as method argument:

I code in:

Select technology of module you want to use:

See Live Example!