macros
Class ENUM_OBJ

java.lang.Object
  |
  +--jatha.Macro
        |
        +--macros.ENUM_OBJ

public class ENUM_OBJ
extends Macro

ENUM_OBJ(className, elem1, name1, elem2, name2, ...)

This macro creates an object-based enumeration. That is, each element of the enumeration is represented as a separate object (as opposed to a C-style enumeration which represent elements as integers). Object-based enumerations are type-safe, while integer-based ones are not. Example: @ENUM_OBJ(Type, INT, "int", DOUBLE, "double") will generate something like this:

 class Type {
     public static final Type INT = new Type("int");
     public static final Type DOUBLE = new Type("double");
 
     public static int getNumElements() {
         return 2;
     }
     public static Type getElement(int __index) {
         switch (__index) {
         case 0: return INT;
         case 1: return DOUBLE;
         default: return null;
         }
     }
     public static Type getElement(String __name) {
         if (__name.equals("int")) return INT;
         if (__name.equals("double")) return DOUBLE;
         return null;
     }
     private Type(String __description) {
         this.__description = __description;
     }
     private String __description;
     public String toString() {
         return __description;
     }
 }
 

Note: this macro declares an entire class, unlike ENUM_INT and ENUM_BITS which only declare some member variables and methods.

Also note: no class modifiers are generated, so by default the class only has package visibility. If you want to make the class public or private, you need to put modifiers before the macro. For example: public @ENUM_OBJ(...).

See Also:
ENUM_INT, ENUM_BITS

Fields inherited from class jatha.Macro
util
 
Constructor Summary
ENUM_OBJ()
           
 
Method Summary
 void expand(java.lang.String[] args, java.io.Writer out, Expander expander)
          Expands the macro
 
Methods inherited from class jatha.Macro
expand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ENUM_OBJ

public ENUM_OBJ()
Method Detail

expand

public void expand(java.lang.String[] args,
                   java.io.Writer out,
                   Expander expander)
            throws java.io.IOException
Expands the macro
Overrides:
expand in class Macro