A Slice enumeration maps to the corresponding enumeration in Java. For example:
Slice
enum Fruit { Apple, Pear, Orange };
The Java mapping for Fruit
is shown below:
Java
public enum Fruit implements java.io.Serializable { Apple, Pear, Orange; // ... }
Given the above definitions, we can use enumerated values as follows:
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; }
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).