Android examples for java.lang:Enum
Simply unpacks an enumerated for a given integer-containing string.
//package com.java2s; public class Main { /**// w ww .ja va2 s . c o m * Simply unpacks an enumerated for a given integer-containing string. * @param value An enumerated type expressed as an int, inside a string * @param aClass The enumerated type in question * @return The corresponding enumerated type for the given integer string */ public static <T extends Enum<?>> T forIntString(String value, Class<T> aClass) { int intValue = Integer.parseInt(value); return aClass.getEnumConstants()[intValue]; } }