Java Code Examples for com.google.common.collect.Iterators#contains()

The following examples show how to use com.google.common.collect.Iterators#contains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeleteContactsAndHostsAction.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Override
public void reduce(final DeletionRequest deletionRequest, ReducerInput<Boolean> values) {
  final boolean hasNoActiveReferences = !Iterators.contains(values, true);
  logger.atInfo().log("Processing async deletion request for %s", deletionRequest.key());
  DeletionResult result =
      tm()
          .transactNew(
              () -> {
                DeletionResult deletionResult =
                    attemptToDeleteResource(deletionRequest, hasNoActiveReferences);
                getQueue(QUEUE_ASYNC_DELETE).deleteTask(deletionRequest.task());
                return deletionResult;
              });
  asyncTaskMetrics.recordAsyncFlowResult(
      deletionRequest.getMetricOperationType(),
      result.getMetricOperationResult(),
      deletionRequest.requestedTime());
  String resourceNamePlural = deletionRequest.key().getKind() + "s";
  getContext().incrementCounter(result.type().renderCounterText(resourceNamePlural));
  logger.atInfo().log(
      "Result of async deletion for resource %s: %s",
      deletionRequest.key(), result.pollMessageText());
}
 
Example 2
Source File: SequenceTSData.java    From monsoon with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean contains(Object o) {
    if (!(o instanceof TimeSeriesCollection))
        return false;
    ObjectSequence<TimeSeriesCollection> seq = getSequence();
    final EqualRange range = seq.equalRange(tsc -> tsc.compareTo((TimeSeriesCollection) o));
    if (range.isEmpty())
        return false;
    seq = seq.limit(range.getEnd()).skip(range.getBegin());
    return Iterators.contains(seq.iterator(), o);
}
 
Example 3
Source File: Guava.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@ExpectWarning(value="GC", num=5)
public static void testIterators(Iterator<String> i, Collection<Integer> c) {
    Iterators.contains(i, 1);
    Iterators.removeAll(i,c);
    Iterators.retainAll(i, c);
    Iterators.elementsEqual(i, c.iterator());
    Iterators.frequency(i, 1);
}
 
Example 4
Source File: Guava.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@NoWarning("GC")
public static void testIteratorsOK(Iterator<String> i, Collection<String> c) {
    Iterators.contains(i, "x");
    Iterators.removeAll(i,c);
    Iterators.retainAll(i, c);
    Iterators.elementsEqual(i, c.iterator());
    Iterators.frequency(i, "x");
}
 
Example 5
Source File: CollectionUtils.java    From SnowGraph with Apache License 2.0 4 votes vote down vote up
@Override
public boolean contains(Object o) {
	return o != null && Iterators.contains(this.iterator(), o);
}
 
Example 6
Source File: SetUtils.java    From SnowGraph with Apache License 2.0 4 votes vote down vote up
@Override
public boolean contains(Object o) {
	return o != null && Iterators.contains(this.iterator(), o);
}
 
Example 7
Source File: CollectionHelpers.java    From pravega with Apache License 2.0 4 votes vote down vote up
@Override
public boolean contains(Object o) {
    return Iterators.contains(iterator(), o);
}
 
Example 8
Source File: StackedReversePathArguments.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
@Override
@SuppressWarnings("checkstyle:parameterName")
public boolean contains(final Object o) {
    final PathArgument srch = (PathArgument) requireNonNull(o);
    return Iterators.contains(iterator(), srch);
}