blob: dbdb4926058751a7e02809d9219299e08d433e9b [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.lib.json;
2
3import java.io.*;
4import java.lang.reflect.*;
5import java.util.*;
6
7public class EnumHandler extends Handler {
8 @SuppressWarnings("rawtypes")
9 final Class type;
10
11 public EnumHandler(Class<?> type) {
12 this.type = type;
13 }
14
15 @Override void encode(Encoder app, Object object, Map<Object, Type> visited)
16 throws IOException, Exception {
17 StringHandler.string(app, object.toString());
18 }
19
20 @SuppressWarnings("unchecked") Object decode(String s) throws Exception {
21 return Enum.valueOf(type, s);
22 }
23
24}