@SuppressWarnings("unchecked") public static <T> Set<T> unmodifiableSet(T... values) { return unmodifiableSet(arrayListOf(values)); }
/** * Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single * string value into multiple values. * * @param key the key for the configuration property * @param regex the delimiting regular expression * @return the list of string values; null only if there is no such key-value pair in the configuration * @see String#split(String) */ default List<String> getStrings(String key, String regex) { String value = getString(key); if (value == null) return null; return Collect.arrayListOf(value.split(regex)); }
protected void appendLinesToSource(int numberOfLines) throws IOException { CharSequence[] lines = new CharSequence[numberOfLines]; for (int i = 0; i != numberOfLines; ++i) { lines[i] = generateLine(linesAdded + i + 1); } java.nio.file.Files.write(inputFile.toPath(), Collect.arrayListOf(lines), UTF8, StandardOpenOption.APPEND); linesAdded += numberOfLines; }
historyConsumer.subscribe(Collect.arrayListOf(topicName));
@Test public void shouldFilterServerUuids() { String gtidStr = "036d85a9-64e5-11e6-9b48-42010af0000c:1-2," + "7145bf69-d1ca-11e5-a588-0242ac110004:1-3200," + "7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"; Collection<String> keepers = Collect.arrayListOf("036d85a9-64e5-11e6-9b48-42010af0000c", "7c1de3f2-3fd2-11e6-9cdc-42010af000bc", "wont-be-found"); GtidSet original = new GtidSet(gtidStr); assertThat(original.forServerWithId("036d85a9-64e5-11e6-9b48-42010af0000c")).isNotNull(); assertThat(original.forServerWithId("7c1de3f2-3fd2-11e6-9cdc-42010af000bc")).isNotNull(); assertThat(original.forServerWithId("7145bf69-d1ca-11e5-a588-0242ac110004")).isNotNull(); GtidSet filtered = original.retainAll(keepers::contains); List<String> actualUuids = filtered.getUUIDSets().stream().map(UUIDSet::getUUID).collect(Collectors.toList()); assertThat(keepers.containsAll(actualUuids)).isTrue(); assertThat(filtered.forServerWithId("7145bf69-d1ca-11e5-a588-0242ac110004")).isNull(); }
@SuppressWarnings("unchecked") public static <T> Set<T> unmodifiableSet(T... values) { return unmodifiableSet(arrayListOf(values)); }
/** * Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single * string value into multiple values. * * @param key the key for the configuration property * @param regex the delimiting regular expression * @return the list of string values; null only if there is no such key-value pair in the configuration * @see String#split(String) */ default List<String> getStrings(String key, String regex) { String value = getString(key); if (value == null) return null; return Collect.arrayListOf(value.split(regex)); }
protected void appendLinesToSource(int numberOfLines) throws IOException { CharSequence[] lines = new CharSequence[numberOfLines]; for (int i = 0; i != numberOfLines; ++i) { lines[i] = generateLine(linesAdded + i + 1); } java.nio.file.Files.write(inputFile.toPath(), Collect.arrayListOf(lines), UTF8, StandardOpenOption.APPEND); linesAdded += numberOfLines; }
historyConsumer.subscribe(Collect.arrayListOf(topicName));
@Test public void shouldFilterServerUuids() { String gtidStr = "036d85a9-64e5-11e6-9b48-42010af0000c:1-2," + "7145bf69-d1ca-11e5-a588-0242ac110004:1-3200," + "7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"; Collection<String> keepers = Collect.arrayListOf("036d85a9-64e5-11e6-9b48-42010af0000c", "7c1de3f2-3fd2-11e6-9cdc-42010af000bc", "wont-be-found"); GtidSet original = new GtidSet(gtidStr); assertThat(original.forServerWithId("036d85a9-64e5-11e6-9b48-42010af0000c")).isNotNull(); assertThat(original.forServerWithId("7c1de3f2-3fd2-11e6-9cdc-42010af000bc")).isNotNull(); assertThat(original.forServerWithId("7145bf69-d1ca-11e5-a588-0242ac110004")).isNotNull(); GtidSet filtered = original.retainAll(keepers::contains); List<String> actualUuids = filtered.getUUIDSets().stream().map(UUIDSet::getUUID).collect(Collectors.toList()); assertThat(keepers.containsAll(actualUuids)).isTrue(); assertThat(filtered.forServerWithId("7145bf69-d1ca-11e5-a588-0242ac110004")).isNull(); }