@Test(expected = IllegalArgumentException.class) public void testparseEventArrayError() { EventJsonParser.parseEventArray("something:invalid"); }
@SuppressWarnings("unchecked") public static Event[] parseEventArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> evtMap = objectMapper.readValue(json, List.class); Event[] eArray = new Event[evtMap.size()]; int idx = 0; for (LinkedHashMap<String, Object> ll : evtMap) { eArray[idx++] = parseEventMap(ll); } return eArray; } catch (Exception e) { throw new IllegalArgumentException("Cannot parse JSON " + json, e); } }
EventJsonParser { @SuppressWarnings("unchecked") public static Event[] parseEventArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> evtMap = objectMapper.readValue(json, List.class); Event[] eArray = new Event[evtMap.size()]; int idx = 0; for (LinkedHashMap<String, Object> ll : evtMap) { eArray[idx++] = parseEventMap(ll); } return eArray; } catch (Exception e) { throw new IllegalArgumentException("Cannot parse JSON " + json, e); } } }
EventJsonParser { @SuppressWarnings("unchecked") public static Event[] parseEventArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> evtMap = objectMapper.readValue(json, List.class); Event[] eArray = new Event[evtMap.size()]; int idx = 0; for (LinkedHashMap<String, Object> ll : evtMap) { eArray[idx++] = parseEventMap(ll); } return eArray; } catch (Exception e) { throw new IllegalArgumentException("Cannot parse JSON " + json, e); } } private  EventJsonParser(); }
EventJsonParser { @SuppressWarnings("unchecked") public static Event[] parseEventArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> evtMap = objectMapper.readValue(json, List.class); Event[] eArray = new Event[evtMap.size()]; int idx = 0; for (LinkedHashMap<String, Object> ll : evtMap) { eArray[idx++] = parseEventMap(ll); } return eArray; } catch (Exception e) { throw new IllegalArgumentException("Cannot parse JSON " + json, e); } } private  EventJsonParser(); @SuppressWarnings("unchecked") static Event parseEvent(String json); static String eventArrayToJson(Event[] events); @SuppressWarnings("unchecked") static Event[] parseEventArray(String json); }
EventJsonParser { @SuppressWarnings("unchecked") public static Event[] parseEventArray(String json) { if (null == json || "".equals(json)) { return null; } try { List<LinkedHashMap<String, Object>> evtMap = objectMapper.readValue(json, List.class); Event[] eArray = new Event[evtMap.size()]; int idx = 0; for (LinkedHashMap<String, Object> ll : evtMap) { eArray[idx++] = parseEventMap(ll); } return eArray; } catch (Exception e) { throw new IllegalArgumentException("Cannot parse JSON " + json, e); } } private  EventJsonParser(); @SuppressWarnings("unchecked") static Event parseEvent(String json); static String eventArrayToJson(Event[] events); @SuppressWarnings("unchecked") static Event[] parseEventArray(String json);  }