@Test public void testParseIntervalMapDouble() { IntervalDoubleMap expected = new IntervalDoubleMap(); expected.put(new Interval(1, 2), 1d); expected.put(new Interval(3, 5), 2d); expected.put(new Interval(5, 6), 3d); expected.put(new Interval(6, 7), 4d); assertEqualIntervalMaps(expected, IntervalsParser.parseIntervalMap(Double.class, "[1, 2, 1]; [3, 5, 2]; [5, 6, '3']; [6, 7, \"4\"]")); assertEqualIntervalMaps(expected, IntervalsParser.parseIntervalMap(double.class, "[1, 2, 1]; [3, 5, 2]; [5, 6, '3']; [6, 7, \"4\"]")); }
public static <T> IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone) throws IllegalArgumentException { if (typeClass == null) { throw new IllegalArgumentException("typeClass required"); } if (input == null) { return null; } List<IntervalWithValue<T>> intervals; try { intervals = parseIntervals(typeClass, input, timeZone); } catch (IOException ex) { throw new RuntimeException("Unexpected expection while parsing intervals", ex); } int capacity = intervals.size(); IntervalMap result; typeClass = AttributeUtils.getStandardizedType(typeClass); if (typeClass.equals(String.class)) { result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity); } else if (typeClass.equals(Integer.class)) { result = new IntervalIntegerMap(capacity); } else if (typeClass.equals(Long.class)) { result = new IntervalLongMap(capacity); } else if (typeClass.equals(Float.class)) { result = new IntervalFloatMap(capacity); } else if (typeClass.equals(Double.class)) { result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity); } else { throw new IllegalArgumentException("Unsupported type " + typeClass.getClass().getCanonicalName()); } for (IntervalWithValue<T> interval : intervals) { T value = interval.getValue(); if (value == null) { throw new IllegalArgumentException("A value must be provided for each interval"); } result.put(interval.getInterval(), interval.getValue()); } return result; }
IntervalsParser { public static <T> IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone) throws IllegalArgumentException { if (typeClass == null) { throw new IllegalArgumentException("typeClass required"); } if (input == null) { return null; } List<IntervalWithValue<T>> intervals; try { intervals = parseIntervals(typeClass, input, timeZone); } catch (IOException ex) { throw new RuntimeException("Unexpected expection while parsing intervals", ex); } int capacity = intervals.size(); IntervalMap result; typeClass = AttributeUtils.getStandardizedType(typeClass); if (typeClass.equals(String.class)) { result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity); } else if (typeClass.equals(Integer.class)) { result = new IntervalIntegerMap(capacity); } else if (typeClass.equals(Long.class)) { result = new IntervalLongMap(capacity); } else if (typeClass.equals(Float.class)) { result = new IntervalFloatMap(capacity); } else if (typeClass.equals(Double.class)) { result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity); } else { throw new IllegalArgumentException("Unsupported type " + typeClass.getClass().getCanonicalName()); } for (IntervalWithValue<T> interval : intervals) { T value = interval.getValue(); if (value == null) { throw new IllegalArgumentException("A value must be provided for each interval"); } result.put(interval.getInterval(), interval.getValue()); } return result; } }
IntervalsParser { public static <T> IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone) throws IllegalArgumentException { if (typeClass == null) { throw new IllegalArgumentException("typeClass required"); } if (input == null) { return null; } List<IntervalWithValue<T>> intervals; try { intervals = parseIntervals(typeClass, input, timeZone); } catch (IOException ex) { throw new RuntimeException("Unexpected expection while parsing intervals", ex); } int capacity = intervals.size(); IntervalMap result; typeClass = AttributeUtils.getStandardizedType(typeClass); if (typeClass.equals(String.class)) { result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity); } else if (typeClass.equals(Integer.class)) { result = new IntervalIntegerMap(capacity); } else if (typeClass.equals(Long.class)) { result = new IntervalLongMap(capacity); } else if (typeClass.equals(Float.class)) { result = new IntervalFloatMap(capacity); } else if (typeClass.equals(Double.class)) { result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity); } else { throw new IllegalArgumentException("Unsupported type " + typeClass.getClass().getCanonicalName()); } for (IntervalWithValue<T> interval : intervals) { T value = interval.getValue(); if (value == null) { throw new IllegalArgumentException("A value must be provided for each interval"); } result.put(interval.getInterval(), interval.getValue()); } return result; }  }
IntervalsParser { public static <T> IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone) throws IllegalArgumentException { if (typeClass == null) { throw new IllegalArgumentException("typeClass required"); } if (input == null) { return null; } List<IntervalWithValue<T>> intervals; try { intervals = parseIntervals(typeClass, input, timeZone); } catch (IOException ex) { throw new RuntimeException("Unexpected expection while parsing intervals", ex); } int capacity = intervals.size(); IntervalMap result; typeClass = AttributeUtils.getStandardizedType(typeClass); if (typeClass.equals(String.class)) { result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity); } else if (typeClass.equals(Integer.class)) { result = new IntervalIntegerMap(capacity); } else if (typeClass.equals(Long.class)) { result = new IntervalLongMap(capacity); } else if (typeClass.equals(Float.class)) { result = new IntervalFloatMap(capacity); } else if (typeClass.equals(Double.class)) { result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity); } else { throw new IllegalArgumentException("Unsupported type " + typeClass.getClass().getCanonicalName()); } for (IntervalWithValue<T> interval : intervals) { T value = interval.getValue(); if (value == null) { throw new IllegalArgumentException("A value must be provided for each interval"); } result.put(interval.getInterval(), interval.getValue()); } return result; }  static IntervalSet parseIntervalSet(String input, DateTimeZone timeZone); static IntervalSet parseIntervalSet(String input); static IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone); static IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input); }
IntervalsParser { public static <T> IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone) throws IllegalArgumentException { if (typeClass == null) { throw new IllegalArgumentException("typeClass required"); } if (input == null) { return null; } List<IntervalWithValue<T>> intervals; try { intervals = parseIntervals(typeClass, input, timeZone); } catch (IOException ex) { throw new RuntimeException("Unexpected expection while parsing intervals", ex); } int capacity = intervals.size(); IntervalMap result; typeClass = AttributeUtils.getStandardizedType(typeClass); if (typeClass.equals(String.class)) { result = new IntervalStringMap(capacity); } else if (typeClass.equals(Byte.class)) { result = new IntervalByteMap(capacity); } else if (typeClass.equals(Short.class)) { result = new IntervalShortMap(capacity); } else if (typeClass.equals(Integer.class)) { result = new IntervalIntegerMap(capacity); } else if (typeClass.equals(Long.class)) { result = new IntervalLongMap(capacity); } else if (typeClass.equals(Float.class)) { result = new IntervalFloatMap(capacity); } else if (typeClass.equals(Double.class)) { result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity); } else { throw new IllegalArgumentException("Unsupported type " + typeClass.getClass().getCanonicalName()); } for (IntervalWithValue<T> interval : intervals) { T value = interval.getValue(); if (value == null) { throw new IllegalArgumentException("A value must be provided for each interval"); } result.put(interval.getInterval(), interval.getValue()); } return result; }  static IntervalSet parseIntervalSet(String input, DateTimeZone timeZone); static IntervalSet parseIntervalSet(String input); static IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input, DateTimeZone timeZone); static IntervalMap<T> parseIntervalMap(Class<T> typeClass, String input);  }