@@ -0,0 +1,1101 @@
+package nl.tudelft.watchdog.logic.interval.active;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport nl.tudelft.watchdog.util.GSONUtil;%0A%0A/**%0A * Construct intervals from textual representations.%0A */%0Apublic class IntervalFactory %7B%0A%0A%09static Map%3CIntervalType, Class%3C? extends IntervalBase%3E%3E intervalTypes = new HashMap%3C%3E();%0A%0A%09static %7B%0A%09%09intervalTypes.put(IntervalType.Reading, ReadingInterval.class);%0A%09%09intervalTypes.put(IntervalType.Session, SessionInterval.class);%0A%09%09intervalTypes.put(IntervalType.Typing, TypingInterval.class);%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 */%0A%09public static %3CT extends IntervalBase%3E T fromJSON(String json) %7B%0A%09%09Map%3CString, String%3E tmp = new HashMap%3CString, String%3E();%0A%09%09tmp = GSONUtil.gson().fromJson(json, tmp.getClass());%0A%0A%09%09Class%3C? extends IntervalBase%3E type = intervalTypes.get(IntervalType%0A%09%09%09%09.fromMnemonic(tmp.get(%22at%22)));%0A%09%09return (T) fromJSON(json, type);%0A%09%7D%0A%0A%09/**%0A%09 * Construct an IntervalBase subtype using a JSON string as input.%0A%09 */%0A%09public static %3CT extends IntervalBase%3E T fromJSON(String json, Class%3CT%3E type) %7B%0A%09%09T a = GSONUtil.gson().fromJson(json, type);%0A%09%09return a;%0A%09%7D%0A%7D%0A

Create Intervals from text (JSON ATM)