summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/parser/EnumParser.java')
-rw-r--r--src/com/isode/stroke/parser/EnumParser.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/EnumParser.java b/src/com/isode/stroke/parser/EnumParser.java
new file mode 100644
index 0000000..2d35c79
--- /dev/null
+++ b/src/com/isode/stroke/parser/EnumParser.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class EnumParser<T> {
+
+ private Map<String, T> values = new HashMap<String, T>();
+
+ public EnumParser() {
+
+ }
+
+ public EnumParser addValue(T value, String text) {
+ values.put(text, value);
+ return this;
+ }
+
+ public T parse(String value) {
+ if(values.containsKey(value)) {
+ return values.get(value);
+ } else {
+ return null;
+ }
+ }
+} \ No newline at end of file