@Test public void factoryHandlesMultipleValues() { final String id1 = "test-id-one"; final String id2 = "test-id-two"; final String id3 = "test-id-three"; final String idListStr = String.join(",",id1, id2, id3); final Config c = ConfigFactory.parseString("iep.leader.resourceIds = [" + idListStr + "]"); final Collection<ResourceId> actualResourceIds = ResourceId.create(c); assertThat(actualResourceIds).containsExactly( new ResourceId(id1), new ResourceId(id2), new ResourceId(id3) ); }
public static Collection<ResourceId> create(Config config) { final Collection<ResourceId> resourceIds; if (config.hasPath(RESOURCE_IDS_CONFIG_PATH)) { resourceIds = config.getStringList(RESOURCE_IDS_CONFIG_PATH) .stream() .map(ResourceId::new) .collect(Collectors.toList()); } else { resourceIds = Collections.emptyList(); } return resourceIds; }
ResourceId { public static Collection<ResourceId> create(Config config) { final Collection<ResourceId> resourceIds; if (config.hasPath(RESOURCE_IDS_CONFIG_PATH)) { resourceIds = config.getStringList(RESOURCE_IDS_CONFIG_PATH) .stream() .map(ResourceId::new) .collect(Collectors.toList()); } else { resourceIds = Collections.emptyList(); } return resourceIds; } }
ResourceId { public static Collection<ResourceId> create(Config config) { final Collection<ResourceId> resourceIds; if (config.hasPath(RESOURCE_IDS_CONFIG_PATH)) { resourceIds = config.getStringList(RESOURCE_IDS_CONFIG_PATH) .stream() .map(ResourceId::new) .collect(Collectors.toList()); } else { resourceIds = Collections.emptyList(); } return resourceIds; } ResourceId(String id); }
ResourceId { public static Collection<ResourceId> create(Config config) { final Collection<ResourceId> resourceIds; if (config.hasPath(RESOURCE_IDS_CONFIG_PATH)) { resourceIds = config.getStringList(RESOURCE_IDS_CONFIG_PATH) .stream() .map(ResourceId::new) .collect(Collectors.toList()); } else { resourceIds = Collections.emptyList(); } return resourceIds; } ResourceId(String id); static Collection<ResourceId> create(Config config); String getId(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
ResourceId { public static Collection<ResourceId> create(Config config) { final Collection<ResourceId> resourceIds; if (config.hasPath(RESOURCE_IDS_CONFIG_PATH)) { resourceIds = config.getStringList(RESOURCE_IDS_CONFIG_PATH) .stream() .map(ResourceId::new) .collect(Collectors.toList()); } else { resourceIds = Collections.emptyList(); } return resourceIds; } ResourceId(String id); static Collection<ResourceId> create(Config config); String getId(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final String RESOURCE_IDS_CONFIG_PATH; }