/** * Adds the given servers to the group. */ public void addAllServers(Collection<Address> hostPort){ servers.addAll(hostPort); }
public void addAllTables(Collection<TableName> arg) { tables.addAll(arg); }
/** * Adds the sorted set of {@link LocalizedMessage} to the message collector. * @param messages the sorted set of {@link LocalizedMessage}. */ protected static void addMessages(SortedSet<LocalizedMessage> messages) { MESSAGE_COLLECTOR.get().addAll(messages); }
private Set<GrantedAuthority> sortAuthorities(Collection<? extends GrantedAuthority> authorities) { SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet<>(Comparator.comparing(GrantedAuthority::getAuthority)); sortedAuthorities.addAll(authorities); return sortedAuthorities; }
private static void formFieldValuesToCaps(List<CharSequence> i, StringBuilder sb) { SortedSet<CharSequence> fvs = new TreeSet<>(); fvs.addAll(i); for (CharSequence fv : fvs) { sb.append(fv); sb.append('<'); } }
public List<TopicPartition> allPartitionsSorted(Map<String, Integer> partitionsPerTopic, Map<String, Subscription> subscriptions) { SortedSet<String> topics = new TreeSet<>(); for (Subscription subscription : subscriptions.values()) topics.addAll(subscription.topics()); List<TopicPartition> allPartitions = new ArrayList<>(); for (String topic : topics) { Integer numPartitionsForTopic = partitionsPerTopic.get(topic); if (numPartitionsForTopic != null) allPartitions.addAll(AbstractPartitionAssignor.partitions(topic, numPartitionsForTopic)); } return allPartitions; }
private static List<String> getSelectedQueryTagNames(Iterable<Suite> suites, Iterable<BenchmarkQuery> queries) { SortedSet<String> tags = new TreeSet<>(); for (Suite suite : suites) { for (BenchmarkQuery query : suite.selectQueries(queries)) { tags.addAll(query.getTags().keySet()); } for (RegexTemplate regexTemplate : suite.getSchemaNameTemplates()) { tags.addAll(regexTemplate.getFieldNames()); } } return ImmutableList.copyOf(tags); }
List<Object> getSupportedEncodings() { // no need for synchronization - in case of a race condition, the property // may be set twice, but it does not break anything if (supportedEncodings == null) { SortedSet<String> se = new TreeSet<>(); List<ContentEncoder> encoders = injectionManager.getAllInstances(ContentEncoder.class); for (ContentEncoder encoder : encoders) { se.addAll(encoder.getSupportedEncodings()); } supportedEncodings = new ArrayList<>(se); } return supportedEncodings; } }
List<Object> getSupportedEncodings() { // no need for synchronization - in case of a race condition, the property // may be set twice, but it does not break anything if (supportedEncodings == null) { SortedSet<String> se = new TreeSet<>(); List<ContentEncoder> encoders = injectionManager.getAllInstances(ContentEncoder.class); for (ContentEncoder encoder : encoders) { se.addAll(encoder.getSupportedEncodings()); } supportedEncodings = new ArrayList<>(se); } return supportedEncodings; } }
public Set<String> rolesThatCanOperateOnStage(CruiseConfig cruiseConfig, PipelineConfig pipelineConfig) { PipelineConfigs group = cruiseConfig.findGroupOfPipeline(pipelineConfig); SortedSet<String> roles = new TreeSet<>(); if (group.hasAuthorizationDefined()) { if (group.hasOperationPermissionDefined()) { roles.addAll(group.getOperateRoleNames()); } } else { roles.addAll(allRoleNames(cruiseConfig)); } return roles; }
/** * @param strings The completer strings */ public StringsCompleter(final Collection<String> strings) { checkNotNull(strings); getStrings().addAll(strings); }
@Override public int complete(String buffer, int cursor, List<CharSequence> candidates) { if (cursor <= 0) { return cursor; } int blankPos = findLastBlank(buffer.substring(0, cursor)); String prefix = buffer.substring(blankPos + 1, cursor); String schemaName = queryRunner.getSession().getSchema(); if (schemaName != null) { List<String> functionNames = functionCache.getIfPresent(schemaName); List<String> tableNames = tableCache.getIfPresent(schemaName); SortedSet<String> sortedCandidates = new TreeSet<>(); if (functionNames != null) { sortedCandidates.addAll(filterResults(functionNames, prefix)); } if (tableNames != null) { sortedCandidates.addAll(filterResults(tableNames, prefix)); } candidates.addAll(sortedCandidates); } return blankPos + 1; }
@SuppressWarnings("CollectionIncompatibleType") // testing incompatible types public void testContainsAll_sameComparator_StringVsInt() { SortedSet<String> set = of("a", "b", "f"); SortedSet<Integer> unexpected = Sets.newTreeSet(Ordering.natural()); unexpected.addAll(asList(1, 2, 3)); assertFalse(set.containsAll(unexpected)); }
@Override public GapAwareTrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof GapAwareTrackingToken, () -> "Incompatible token type provided."); GapAwareTrackingToken otherToken = (GapAwareTrackingToken) other; SortedSet<Long> mergedGaps = new ConcurrentSkipListSet<>(this.gaps); mergedGaps.addAll(otherToken.gaps); long mergedIndex = calculateIndex(otherToken, mergedGaps); mergedGaps.removeIf(i -> i >= mergedIndex); return new GapAwareTrackingToken(mergedIndex, mergedGaps); }
void ensureNotDirectlyModifiable(SortedSet<Integer> unmod) { try { unmod.add(4); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { unmod.remove(4); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { unmod.addAll(Collections.singleton(4)); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } try { Iterator<Integer> iterator = unmod.iterator(); iterator.next(); iterator.remove(); fail("UnsupportedOperationException expected"); } catch (UnsupportedOperationException expected) { } }
public Set<String> usersThatCanOperateOnStage(CruiseConfig cruiseConfig, PipelineConfig pipelineConfig) { SortedSet<String> users = new TreeSet<>(); PipelineConfigs group = cruiseConfig.findGroupOfPipeline(pipelineConfig); if (group.hasAuthorizationDefined()) { if (group.hasOperationPermissionDefined()) { users.addAll(group.getOperateUserNames()); List<String> roles = group.getOperateRoleNames(); for (Role role : cruiseConfig.server().security().getRoles()) { if (roles.contains(CaseInsensitiveString.str(role.getName()))) { users.addAll(role.usersOfRole()); } } } } else { users.addAll(allUsernames()); } return users; }
public Set makeFullSet() { SortedSet set = new TreeSet(); set.addAll(Arrays.asList(getFullElements())); return TransformedSortedSet.decorate(set, TestTransformedCollection.NOOP_TRANSFORMER); }
SortedSet<Invoice> unpaidInvoicesForAccount(final UUID accountId, final InternalCallContext context) { final Collection<Invoice> invoices = invoiceApi.getUnpaidInvoicesByAccountId(accountId, context.toLocalDate(context.getCreatedDate()), context); final SortedSet<Invoice> sortedInvoices = new TreeSet<Invoice>(new InvoiceDateComparator()); sortedInvoices.addAll(invoices); return sortedInvoices; } }
public AbstractTestSortedBidiMap() { super(); sortedKeys.addAll(Arrays.asList(getSampleValues())); Collections.sort(sortedKeys); sortedKeys = Collections.unmodifiableList(sortedKeys); Map map = new TreeMap(); for (int i = 0; i < getSampleKeys().length; i++) { map.put(getSampleValues()[i], getSampleKeys()[i]); } sortedValues.addAll(map.values()); sortedValues = Collections.unmodifiableList(sortedValues); sortedNewValues.addAll(Arrays.asList(getNewSampleValues())); }
public AbstractTestSortedBidiMap(String testName) { super(testName); sortedKeys.addAll(Arrays.asList(getSampleKeys())); Collections.sort(sortedKeys); sortedKeys = Collections.unmodifiableList(sortedKeys); Map map = new TreeMap(); for (int i = 0; i < getSampleKeys().length; i++) { map.put(getSampleKeys()[i], getSampleValues()[i]); } sortedValues.addAll(map.values()); sortedValues = Collections.unmodifiableList(sortedValues); sortedNewValues.addAll(Arrays.asList(getNewSampleValues())); }