1
2
3
4
5
6
7
8
9
10
11 package org.csveed.bean.conversion;
12
13
14
15
16
17
18
19 public class EnumConverter<T extends Enum> extends AbstractConverter<T> {
20
21
22 public final Class<T> enumClass;
23
24
25
26
27
28
29
30 public EnumConverter(Class<T> enumClass) {
31 super(enumClass);
32 this.enumClass = enumClass;
33 }
34
35 @Override
36 public T fromString(String text) throws Exception {
37 return (T) Enum.valueOf(this.enumClass, text);
38 }
39
40 @Override
41 public String toString(T value) throws Exception {
42 return value.toString();
43 }
44
45 }