@Override Collection<Integer> filter(Collection<Integer> elements, Predicate<? super Integer> predicate) { return Collections2.filter(elements, predicate); } }
static <E> Collection<E> filterCollection( Collection<E> collection, Predicate<? super E> predicate) { if (collection instanceof Set) { return Sets.filter((Set<E>) collection, predicate); } else { return Collections2.filter(collection, predicate); } }
@Override public String toString() { return MoreObjects.toStringHelper(ServiceManager.class) .add("services", Collections2.filter(services, not(instanceOf(NoOpService.class)))) .toString(); }
/** * Get aggregation distinct column label. * * @param aggregationDistinctColumnIndex aggregation distinct column index * @return aggregation distinct column label */ public String getAggregationDistinctColumnLabel(final int aggregationDistinctColumnIndex) { return Collections2.filter(columnMetaDataList, new Predicate<AggregationDistinctColumnMetaData>() { @Override public boolean apply(final AggregationDistinctColumnMetaData input) { return aggregationDistinctColumnIndex == input.columnIndex; } }).iterator().next().columnLabel; }
/** * Get aggregation distinct column index. * * @param aggregationDistinctColumnLabel aggregation distinct column label * @return aggregation distinct column index */ public int getAggregationDistinctColumnIndex(final String aggregationDistinctColumnLabel) { return Collections2.filter(columnMetaDataList, new Predicate<AggregationDistinctColumnMetaData>() { @Override public boolean apply(final AggregationDistinctColumnMetaData input) { return aggregationDistinctColumnLabel.equals(input.columnLabel); } }).iterator().next().columnIndex; }
/** * Get aggregation type. * * @param distinctColumnIndex distinct column index * @return aggregation type */ public AggregationType getAggregationType(final int distinctColumnIndex) { return Collections2.filter(columnMetaDataList, new Predicate<AggregationDistinctColumnMetaData>() { @Override public boolean apply(final AggregationDistinctColumnMetaData input) { return distinctColumnIndex == input.columnIndex; } }).iterator().next().aggregationType; }
/** * Get aggregation distinct column index. * * @param derivedSumIndex derived sum index * @return aggregation distinct column index */ public int getAggregationDistinctColumnIndex(final int derivedSumIndex) { return Collections2.filter(columnMetaDataList, new Predicate<AggregationDistinctColumnMetaData>() { @Override public boolean apply(final AggregationDistinctColumnMetaData input) { return derivedSumIndex == input.derivedSumIndex; } }).iterator().next().columnIndex; }
private static Collection<ShardingEncryptor> loadEncryptors(final String encryptorType) { return Collections2.filter(NewInstanceServiceLoader.newServiceInstances(ShardingEncryptor.class), new Predicate<ShardingEncryptor>() { @Override public boolean apply(final ShardingEncryptor input) { return encryptorType.equalsIgnoreCase(input.getType()); } }); } }
private static Collection<ShardingKeyGenerator> loadKeyGenerators(final String keyGeneratorType) { return Collections2.filter(NewInstanceServiceLoader.newServiceInstances(ShardingKeyGenerator.class), new Predicate<ShardingKeyGenerator>() { @Override public boolean apply(final ShardingKeyGenerator input) { return keyGeneratorType.equalsIgnoreCase(input.getType()); } }); } }
@Override public String toString() { return MoreObjects.toStringHelper(ServiceManager.class) .add("services", Collections2.filter(services, not(instanceOf(NoOpService.class)))) .toString(); }
static <E> Collection<E> filterCollection( Collection<E> collection, Predicate<? super E> predicate) { if (collection instanceof Set) { return Sets.filter((Set<E>) collection, predicate); } else { return Collections2.filter(collection, predicate); } }
@Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); Collections.addAll(unfiltered, elements); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } })
@Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); unfiltered.add("abc"); return Collections2.filter(Collections2.filter(unfiltered, LENGTH_1), NOT_YYY_ZZZ); } })
@Override public Iterable<Message> getMessages(MessageType... types) { final List<MessageType> allowedTypes = Arrays.asList(types); return Collections2.filter(messageHistory, input -> allowedTypes.contains(input.getType())); }
@Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } })
@Override public Collection<String> create(String[] elements) { List<String> unfiltered = newLinkedList(); unfiltered.add("yyy"); Collections.addAll(unfiltered, elements); unfiltered.add("zzz"); return Collections2.filter(unfiltered, NOT_YYY_ZZZ); } })
@Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); return Collections2.filter(unfiltered, LENGTH_1); } })
private int getCurrValidWorkers(Collection<ImmutableWorkerInfo> workers) { final Predicate<ImmutableWorkerInfo> isValidWorker = ProvisioningUtil.createValidWorkerPredicate(config); final int currValidWorkers = Collections2.filter(workers, isValidWorker).size(); log.debug("Current valid workers: %d", currValidWorkers); return currValidWorkers; }
private void sortProcessorChain() { final MessageProcessorsConfig config = clusterConfigService.get(MessageProcessorsConfig.class); if (config != null) { // if we have an explicit ordering use that (unknown last, partial ordering over the given list) classNameOrdering = new LenientExplicitOrdering<>(config.processorOrder()); } final ImmutableList<MessageProcessor> sortedCopy = classNameOrdering.onResultOf(mp -> mp.getClass().getCanonicalName()).immutableSortedCopy(processors); final Collection<MessageProcessor> enabledMessageProcessors = Collections2.filter(sortedCopy, mp -> config == null || !config.disabledProcessors().contains(mp.getClass().getCanonicalName())); LOG.debug("New active message processors: {}", enabledMessageProcessors); sortedProcessors.set(ImmutableList.copyOf(enabledMessageProcessors)); }
@Override public void update(float delta) { super.update(delta); if (!updateComplete) { if (downloader.isDone()) { updateComplete = true; } listedServers.clear(); listedServers.addAll(Collections2.filter(downloader.getServers(), activeServersOnly)); } }