View Javadoc
1   package org.csveed.bean.conversion;
2   
3   public class EnumConverter<T extends Enum> extends AbstractConverter<T> {
4   
5       public Class<T> enumClass;
6   
7       public EnumConverter(Class<T> enumClass) {
8           super(enumClass);
9           this.enumClass = enumClass;
10      }
11  
12      @Override
13      public T fromString(String text) throws Exception {
14          return (T)Enum.valueOf(this.enumClass, text);
15      }
16  
17      @Override
18      public String toString(T value) throws Exception {
19          return value.toString();
20      }
21  
22  }