Datasource { public static List<Datasource> datasources(final String ds) { if (ds.contains(",")) { return stream(ds.split(",")).map(Datasource::datasource).collect(toList()); } else { return singletonList(datasource(ds)); } } private  Datasource(final String node,
                       final int port,
                       final String resource); static List<Datasource> datasources(final String ds); @JsonCreator static Datasource datasource(final String ds); static Datasource datasource(final String node,
                                        final int port,
                                        final String resource); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); final String node; final int port; final String resource; }
@Test public void shouldParseListOfDatasources() { final List<Datasource> testee = datasources("foo:42/bar,foobar"); assertThat(testee.get(0).node).isEqualTo("foo"); assertThat(testee.get(0).port).isEqualTo(42); assertThat(testee.get(0).resource).isEqualTo("bar"); assertThat(testee.get(1).node).isEqualTo("foobar"); assertThat(testee.get(1).port).isEqualTo(-1); assertThat(testee.get(1).resource).isEqualTo(""); }