Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Znav
nextJava Mapping for Structures
prevJava Mapping for Built-In Types

A Slice enumeration maps to the corresponding enumeration in Java. For example:

Wiki Markup
{zcode:slice}
enum Fruit { Apple, Pear, Orange };
{zcode}

The Java mapping for Fruit is shown below:

Wiki Markup
{zcode:java}
public enum Fruit implements java.io.Serializable {
    Apple,
    Pear,
    Orange;

    // ...
}
{zcode}

Given the above definitions, we can use enumerated values as follows:

Wiki Markup
{zcode:java}
Fruit f1 = Fruit.Apple;
Fruit f2 = Fruit.Orange;

if (f1 == Fruit.Apple) // Compare with constant
    // ...

if (f1 == f2)                     // Compare two enums
    // ...

switch (f2) {             // Switch on enum
case Fruit.Apple:
    // ...
    break;
case Fruit.Pear
    // ...
    break;
case Fruit.Orange
    // ...
    break;
}
{zcode}

Note that the generated class contains a number of other members, which we have not shown. These members are internal to the Ice run time and you must not use them in your application code (because they may change from release to release).

Ztop
See Also
Zret
Znav
nextJava Mapping for Structures
prevJava Mapping for Built-In Types