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

The following examples show how to use com.google.common.collect.Iterators#getNext() . 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: URIPattern.java    From kite with Apache License 2.0 6 votes vote down vote up
public URIPattern(URI uri) {
  this.pattern = uri;

  Map<String, String> accumulator = Maps.newHashMap();
  if (pattern.isOpaque()) {
    Iterator<String> pathQuery = PATH_QUERY_SPLITTER
        .split(pattern.getSchemeSpecificPart()).iterator();
    this.patternPath = Iterators.getNext(pathQuery, null);
    addQuery(Iterators.getNext(pathQuery, null), accumulator);
  } else {
    patternPath = pattern.getRawPath();
    addQuery(pattern.getRawQuery(), accumulator);
    addAuthority(pattern, accumulator);
  }
  if (pattern.getScheme() != null) {
    accumulator.put(SCHEME, pattern.getScheme());
  }
  this.defaults = ImmutableMap.copyOf(accumulator);
}
 
Example 2
Source File: FailureTracker.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public void add(String reason) {
    count += 1;
    String problem = Iterators.getNext(REASON_SEPARATOR.split(reason).iterator(), "Unknown");
    if (examples.containsKey(problem)) {
        occurrences.put(problem, occurrences.get(problem) + 1);
    } else {
        examples.put(problem, reason);
        occurrences.put(problem, 1);
    }
}
 
Example 3
Source File: FailureTracker.java    From nifi with Apache License 2.0 5 votes vote down vote up
public void add(String reason) {
    count += 1;
    String problem = Iterators.getNext(REASON_SEPARATOR.split(reason).iterator(), "Unknown");
    if (examples.containsKey(problem)) {
        occurrences.put(problem, occurrences.get(problem) + 1);
    } else {
        examples.put(problem, reason);
        occurrences.put(problem, 1);
    }
}
 
Example 4
Source File: LoadingPhaseRunnerTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
public <T extends Postable> T findPost(Class<T> clazz) {
  return Iterators.getNext(
      storedErrors.getPosts().stream().filter(clazz::isInstance).map(clazz::cast).iterator(),
      null);
}
 
Example 5
Source File: MatchManager.java    From PGM with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Get the {@link Match} for the specified {@link CommandSender}.
 *
 * <p>If the {@link CommandSender} is a {@link ConsoleCommandSender}, then the first {@link Match}
 * is returned.
 *
 * @param sender The {@link CommandSender} to lookup.
 * @return The {@link Match} or {@code null} if not found.
 */
@Nullable
default Match getMatch(@Nullable CommandSender sender) {
  if (sender instanceof Entity) return getMatch((Entity) sender);
  if (sender instanceof ConsoleCommandSender) return Iterators.getNext(getMatches(), null);
  return null;
}
 
Example 6
Source File: RunnableContainerRequest.java    From twill with Apache License 2.0 2 votes vote down vote up
/**
 * Remove a resource request and return it.
 * @return The {@link Resource} and {@link Collection} of {@link RuntimeSpecification} or
 *         {@code null} if there is no more request.
 */
Map.Entry<AllocationSpecification, ? extends Collection<RuntimeSpecification>> takeRequest() {
  Map.Entry<AllocationSpecification, Collection<RuntimeSpecification>> next = Iterators.getNext(requests, null);
  return next == null ? null : Maps.immutableEntry(next.getKey(), ImmutableList.copyOf(next.getValue()));
}