Muhammad Umar
Muhammad Umar

Reputation: 11782

Enum type conversion to int

i am trying to use the following code... The Enum class i am using is

public enum AccountType {
        kAccountTypeAsset(0x1000),
        kAccountTypeAssetFixed(0x1010),

        private int value;
        private AccountType(int value)
        {
         this.value = value;    
        }
        public int getValue()
        {
            return value;
        }
    }

    public AccountType accountType = kAccountTypeAsset;
        integerToDB(accountType);
...

/*************************/

public Object integerToDB (Integer i ) 
    {
    if(i == -1)
    {
        return null;
    }
     return i;
    }

How can i use

accountType

as integer.

Upvotes: 0

Views: 213

Answers (2)

Ken Wayne VanderLinde
Ken Wayne VanderLinde

Reputation: 19339

Since your enum has implemented a getValue method, you can use accountType.getValue() to get the integer value stored in accountType.

Upvotes: 1

Brian Dupuis
Brian Dupuis

Reputation: 8176

integerToDB(accountType.getValue()); ?

Upvotes: 2

Related Questions