Public enum Type {
IN ("input parameters "),
OUT ("output parameter "),
VAR ("variable ");
// Define the constructor with parameters so that you can write IN ("....")
Private String des;
Type (String des)
{
This. des = des;
}
Public String getDesc ()
{
Return des;
}
}
Public enum State {
ON {
@ Override
String getInfo (){
Return "open ";
}
}, OFF {
@ Override
String getInfo (){
// TODO Auto-generated method stub
Return null;
}
};
// Extend an abstract method for each value
Abstract String getInfo ();
};
Java prototype of enum:
Public final class Type extends Enum
{
Public static final Type IN;
Public static final Type OUT;
Public static final Type VAR;
Private String des;
Private static final Type ENUM $ VALUES [];
Private Type (String s, int I, String des)
{
Super (s, I );
This. des = des;
}
Public String getDesc ()
{
Return des;
}
Public static Type [] values ()
{
Type atype [];
Int I;
Type atype1 [];
System. arraycopy (atype = ENUM $ VALUES, 0, atype1 = new Type [I = atype. length], 0, I );
Return atype1;
}
Public static Type valueOf (String s)
{
Return (Type) Enum. valueOf (com/sunline/flow/ide/project/navigator/model/Type, s );
}
Static
{
IN = new Type ("IN", 0, "input parameter ");
OUT = new Type ("OUT", 1, "output parameter ");
VAR = new Type ("VAR", 2, "variable ");
ENUM $ VALUES = (new Type [] {
IN, OUT, VAR
});
}
}
Author: lizhensan"