@Test public void testSerialisation() { Event event1 = new Event(); event1.setUuid("e1"); Event event2 = new Event(); event2.setUuid("e2"); Event[] events = {event1, event2}; Assert.assertNotNull(EventJsonParser.eventArrayToJson(events)); Assert.assertNotNull(EventJsonParser.eventArrayToJson(null)); }
public static String eventArrayToJson(Event[] events) { StringBuilder sb = new StringBuilder(); sb.append("["); if (events != null) { boolean first = true; for (Event event : events) { sb.append(first ? "" : ","); sb.append(event.toJson()); first = false; } } sb.append("]"); return sb.toString(); }
EventJsonParser { public static String eventArrayToJson(Event[] events) { StringBuilder sb = new StringBuilder(); sb.append("["); if (events != null) { boolean first = true; for (Event event : events) { sb.append(first ? "" : ","); sb.append(event.toJson()); first = false; } } sb.append("]"); return sb.toString(); } }
EventJsonParser { public static String eventArrayToJson(Event[] events) { StringBuilder sb = new StringBuilder(); sb.append("["); if (events != null) { boolean first = true; for (Event event : events) { sb.append(first ? "" : ","); sb.append(event.toJson()); first = false; } } sb.append("]"); return sb.toString(); } private  EventJsonParser(); }
EventJsonParser { public static String eventArrayToJson(Event[] events) { StringBuilder sb = new StringBuilder(); sb.append("["); if (events != null) { boolean first = true; for (Event event : events) { sb.append(first ? "" : ","); sb.append(event.toJson()); first = false; } } sb.append("]"); return sb.toString(); } private  EventJsonParser(); @SuppressWarnings("unchecked") static Event parseEvent(String json); static String eventArrayToJson(Event[] events); @SuppressWarnings("unchecked") static Event[] parseEventArray(String json); }
EventJsonParser { public static String eventArrayToJson(Event[] events) { StringBuilder sb = new StringBuilder(); sb.append("["); if (events != null) { boolean first = true; for (Event event : events) { sb.append(first ? "" : ","); sb.append(event.toJson()); first = false; } } sb.append("]"); return sb.toString(); } private  EventJsonParser(); @SuppressWarnings("unchecked") static Event parseEvent(String json); static String eventArrayToJson(Event[] events); @SuppressWarnings("unchecked") static Event[] parseEventArray(String json);  }