Enums,use in switch case

Posted by WPS on Stack Overflow See other posts from Stack Overflow or by WPS
Published on 2010-05-14T17:36:46Z Indexed on 2010/05/14 17:44 UTC
Read the original article Hit count: 207

Filed under:

Hi, I have an Enum defined which contains method return type like "String",Float,List,Double etc.

I will be using it in switch case statements. For example my enum is

public enum MethodType {
    DOUBLE,LIST,STRING,ARRAYLIST,FLOAT,LONG;
}

In a property file, I've key value pairs as follows. Test1=String Test2=Double

In my code I'm getting the value for the key. I need to use the VALUE in Switch Case to Determine the Type and based on that I've to implement some logic. For example something like this

switch(MethodType.DOUBLE){
     case DOUBLE:
        //Dobule logic
}

Can someone please help me to implement this?

© Stack Overflow or respective owner

Related posts about enums