DomainParticipantFactory implements FactoryBean<DomainParticipant>, DisposableBean { static List<String> parse(String s) { Iterable<String> ss = Splitter.onPattern(TOKENIZER_REGEX).trimResults().omitEmptyStrings().split(s); String[] strings = Iterables.toArray(ss, String.class); List<String> l = Arrays.asList(strings); return l; } DomainParticipantFactory(int domain);  DomainParticipantFactory(int domain, String discoveryPeers); @Override DomainParticipant getObject(); @Override Class<DomainParticipant> getObjectType(); @Override boolean isSingleton(); @Override void destroy();  }
@Test public void testRegexSplit() throws Exception { List<String> a; a=DomainParticipantFactory.parse("127.10.0.1 127.10.0.2"); Assert.assertEquals(a.size(), 2); a=DomainParticipantFactory.parse("127.10.0.1;127.10.0.2"); Assert.assertEquals(a.size(), 2); a=DomainParticipantFactory.parse("127.10.0.1 127.10.0.2"); Assert.assertEquals(a.size(), 2); a=DomainParticipantFactory.parse("127.10.0.1;127.10.0.2 127.10.0.3"); Assert.assertEquals(a.size(), 3); a=DomainParticipantFactory.parse(""); Assert.assertEquals(a.size(), 0); a=DomainParticipantFactory.parse(" "); Assert.assertEquals(a.size(), 0); a=DomainParticipantFactory.parse(" 127.10.0.1 127.10.0.2 "); Assert.assertEquals(a.size(), 2); Assert.assertEquals(a.get(0), "127.10.0.1"); Assert.assertEquals(a.get(1), "127.10.0.2"); }