Java 类com.google.common.collect.ImmutableCollection 实例源码

项目:guava-mock    文件:AggregateFuture.java   
@Override
protected final void afterDone() {
  super.afterDone();
  RunningState localRunningState = runningState;
  if (localRunningState != null) {
    // Let go of the memory held by the running state
    this.runningState = null;
    ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures =
        localRunningState.futures;
    boolean wasInterrupted = wasInterrupted();

    if (wasInterrupted()) {
      localRunningState.interruptTask();
    }

    if (isCancelled() & futures != null) {
      for (ListenableFuture<?> future : futures) {
        future.cancel(wasInterrupted);
      }
    }
  }
}
项目:Equella    文件:CShuffleList.java   
@Override
public void validate()
{
    if( checkDuplication || forceUnique )
    {
        final Set<String> values = new HashSet<String>();
        for( NameValue nv : namesValues )
        {
            // nv.value is URL encoded, but the name is ok to use
            values.add(nv.getName());
        }
        final ImmutableCollection<String> valuesReadonly = ImmutableSet.copyOf(values);

        // We need to inform the wizard to check for uniqueness every time,
        // no matter what
        final boolean isUnique = getRepository().checkDataUniqueness(getFirstTarget().getXoqlPath(),
            valuesReadonly, !forceUnique);

        setInvalid(forceUnique && !isUnique && !isInvalid(),
            new KeyLabel("wizard.controls.editbox.uniqueerror")); //$NON-NLS-1$
    }
}
项目:googles-monorepo-demo    文件:AggregateFuture.java   
@Override
protected final void afterDone() {
  super.afterDone();
  RunningState localRunningState = runningState;
  if (localRunningState != null) {
    // Let go of the memory held by the running state
    this.runningState = null;
    ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures =
        localRunningState.futures;
    boolean wasInterrupted = wasInterrupted();

    if (wasInterrupted()) {
      localRunningState.interruptTask();
    }

    if (isCancelled() & futures != null) {
      for (ListenableFuture<?> future : futures) {
        future.cancel(wasInterrupted);
      }
    }
  }
}
项目:de.flapdoodle.solid    文件:CollectorsTest.java   
@Test
public void immutableMultiMapCollector() {
    ImmutableMultimap<Integer, Integer> result = Stream.iterate(0, p -> p+1)
            .parallel()
            .limit(GENERATED_ITEMS)
            .collect(Collectors.groupingBy(i -> i % 10));

    assertEquals(GENERATED_ITEMS,result.size());
    assertEquals(10,result.asMap().size());
    for (int i=0;i<10;i++) {
        int key=i;
        ImmutableCollection<Integer> values = result.get(key);
        values.forEach(v -> {
            assertEquals(key,v % 10);
        });
    }
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean removeIf(Predicate<Node> predicate) {
    boolean result;
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        result = this.nodes.values().removeIf(predicate);
    } finally {
        this.nodesLock.unlock();
    }

    if (!result) {
        return false;
    }

    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:LuckPerms    文件:PermissionHolder.java   
/**
 * Sets a permission node
 *
 * @param node the node to set
 */
public DataMutateResult setPermission(Node node) {
    if (hasPermission(node, false) != Tristate.UNDEFINED) {
        return DataMutateResult.ALREADY_HAS;
    }

    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        this.nodes.put(node.getFullContexts().makeImmutable(), node);
    } finally {
        this.nodesLock.unlock();
    }
    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();

    this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
项目:LuckPerms    文件:PermissionHolder.java   
/**
 * Sets a transient permission node
 *
 * @param node the node to set
 */
public DataMutateResult setTransientPermission(Node node) {
    if (hasPermission(node, true) != Tristate.UNDEFINED) {
        return DataMutateResult.ALREADY_HAS;
    }

    ImmutableCollection<Node> before = getTransientNodes().values();

    this.transientNodesLock.lock();
    try {
        this.transientNodes.put(node.getFullContexts().makeImmutable(), node);
    } finally {
        this.transientNodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getTransientNodes().values();

    this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
项目:LuckPerms    文件:PermissionHolder.java   
/**
 * Unsets a permission node
 *
 * @param node the node to unset
 */
public DataMutateResult unsetPermission(Node node) {
    if (hasPermission(node, false) == Tristate.UNDEFINED) {
        return DataMutateResult.LACKS;
    }

    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        this.nodes.get(node.getFullContexts().makeImmutable()).removeIf(e -> e.almostEquals(node));
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
项目:LuckPerms    文件:PermissionHolder.java   
/**
 * Unsets a transient permission node
 *
 * @param node the node to unset
 */
public DataMutateResult unsetTransientPermission(Node node) {
    if (hasPermission(node, true) == Tristate.UNDEFINED) {
        return DataMutateResult.LACKS;
    }

    ImmutableCollection<Node> before = getTransientNodes().values();

    this.transientNodesLock.lock();
    try {
        this.transientNodes.get(node.getFullContexts().makeImmutable()).removeIf(e -> e.almostEquals(node));
    } finally {
        this.transientNodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getTransientNodes().values();
    this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean clearNodes(ContextSet contextSet) {
    ImmutableCollection<Node> before = getEnduringNodes().values();
    this.nodesLock.lock();
    try {
        this.nodes.removeAll(contextSet.makeImmutable());
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();

    if (before.size() == after.size()) {
        return false;
    }

    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean clearParents(boolean giveDefault) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        boolean b = this.nodes.values().removeIf(Node::isGroupNode);
        if (!b) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    if (this.getType().isUser() && giveDefault) {
        this.plugin.getUserManager().giveDefaultIfNeeded((User) this, false);
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean clearMeta(MetaType type) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        if (!this.nodes.values().removeIf(type::matches)) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean clearMeta(MetaType type, ContextSet contextSet) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        SortedSet<Node> nodes = this.nodes.get(contextSet.makeImmutable());
        if (nodes == null) {
            return false;
        }

        boolean b = nodes.removeIf(type::matches);
        if (!b) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean clearMetaKeys(String key, boolean temp) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        boolean b = this.nodes.values().removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key));
        if (!b) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:LuckPerms    文件:PermissionHolder.java   
public boolean clearMetaKeys(String key, ContextSet contextSet, boolean temp) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        SortedSet<Node> nodes = this.nodes.get(contextSet.makeImmutable());
        if (nodes == null) {
            return false;
        }

        boolean b = nodes.removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key));
        if (!b) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
项目:grakn    文件:InsertQueryImpl.java   
/**
 * At least one of {@code tx} and {@code match} must be absent.
 *
 * @param vars a collection of Vars to insert
 * @param match the {@link Match} to insert for each result
 * @param tx the graph to execute on
 */
InsertQueryImpl(ImmutableCollection<VarPatternAdmin> vars, Optional<MatchAdmin> match, Optional<GraknTx> tx) {
    // match and graph should never both be present (should get graph from inner match)
    assert(!match.isPresent() || !tx.isPresent());

    if (vars.isEmpty()) {
        throw GraqlQueryException.noPatterns();
    }

    this.match = match;
    this.tx = tx;

    this.originalVars = vars;

    // Get all variables, including ones nested in other variables
    this.vars = vars.stream().flatMap(v -> v.innerVarPatterns().stream()).collect(toImmutableList());

    for (VarPatternAdmin var : this.vars) {
        var.getProperties().forEach(property -> ((VarPropertyInternal) property).checkInsertable(var));
    }
}
项目:intellij    文件:BlazeConfigurationResolverResult.java   
@Nullable
OCResolveConfiguration getConfigurationForFile(VirtualFile sourceFile) {
  SourceToTargetMap sourceToTargetMap = SourceToTargetMap.getInstance(project);
  ImmutableCollection<TargetKey> targetsForSourceFile =
      sourceToTargetMap.getRulesForSourceFile(VfsUtilCore.virtualToIoFile(sourceFile));
  if (targetsForSourceFile.isEmpty()) {
    return null;
  }

  // If a source file is in two different targets, we can't possibly show how it will be
  // interpreted in both contexts at the same time in the IDE, so just pick the "first" target.
  TargetKey targetKey = targetsForSourceFile.stream().min(TargetKey::compareTo).orElse(null);
  Preconditions.checkNotNull(targetKey);

  return configurationMap.get(targetKey);
}
项目:intellij    文件:BlazeAndroidModelTest.java   
MockJavaPsiFacade(
    Project project, PsiManager psiManager, ImmutableCollection<String> classNames) {
  super(project, psiManager, null, null);
  ImmutableMap.Builder<String, PsiClass> classesBuilder = ImmutableMap.builder();
  ImmutableMap.Builder<String, Long> timestampsBuilder = ImmutableMap.builder();
  for (String className : classNames) {
    VirtualFile virtualFile =
        new MockVirtualFile("/src/" + className.replace('.', '/') + ".java");
    PsiFile psiFile = mock(PsiFile.class);
    when(psiFile.getVirtualFile()).thenReturn(virtualFile);
    PsiClass psiClass = mock(PsiClass.class);
    when(psiClass.getContainingFile()).thenReturn(psiFile);
    classesBuilder.put(className, psiClass);
    timestampsBuilder.put(className, virtualFile.getTimeStamp());
  }
  classes = classesBuilder.build();
  timestamps = timestampsBuilder.build();
}
项目:codebuff    文件:AggregateFuture.java   
@CanIgnoreReturnValue
@Override
public final boolean cancel(boolean mayInterruptIfRunning) {
  // Must get a reference to the futures before we cancel, as they'll be cleared out.
  RunningState localRunningState = runningState;
  ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures = (localRunningState != null) ? localRunningState.futures : null;
  // Cancel all the component futures.
  boolean cancelled = super.cancel(mayInterruptIfRunning);
  // & is faster than the branch required for &&
  if (cancelled & futures != null) {
    for (ListenableFuture<?> future : futures) {
      future.cancel(mayInterruptIfRunning);
    }
  }
  return cancelled;
}
项目:intellij    文件:ImportRoots.java   
public ImportRoots build() {
  ImmutableCollection<WorkspacePath> rootDirectories = rootDirectoriesBuilder.build();
  // for bazel projects, if we're including the workspace root,
  // we force-exclude the bazel artifact directories
  // (e.g. bazel-bin, bazel-genfiles).
  if (buildSystem == BuildSystem.Bazel && hasWorkspaceRoot(rootDirectories)) {
    excludeBuildSystemArtifacts();
  }
  ImmutableSet<WorkspacePath> minimalExcludes =
      WorkspacePathUtil.calculateMinimalWorkspacePaths(excludeDirectoriesBuilder.build());

  // Remove any duplicates, overlapping, or excluded directories
  ImmutableSet<WorkspacePath> minimalRootDirectories =
      WorkspacePathUtil.calculateMinimalWorkspacePaths(rootDirectories, minimalExcludes);

  return new ImportRoots(minimalRootDirectories, minimalExcludes);
}
项目:codebuff    文件:AggregateFuture.java   
@CanIgnoreReturnValue
@Override
public final boolean cancel(boolean mayInterruptIfRunning) {
  // Must get a reference to the futures before we cancel, as they'll be cleared out.
  RunningState localRunningState = runningState;
  ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures = (localRunningState != null) ? localRunningState.futures : null;
  // Cancel all the component futures.
  boolean cancelled = super.cancel(mayInterruptIfRunning);
  // & is faster than the branch required for &&
  if (cancelled & futures != null) {
    for (ListenableFuture<?> future : futures) {
      future.cancel(mayInterruptIfRunning);
    }
  }
  return cancelled;
}
项目:codebuff    文件:AggregateFuture.java   
@CanIgnoreReturnValue
@Override
public final boolean cancel(boolean mayInterruptIfRunning) {
  // Must get a reference to the futures before we cancel, as they'll be cleared out.
  RunningState localRunningState = runningState;
  ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures = (localRunningState != null) ? localRunningState.futures : null;
  // Cancel all the component futures.
  boolean cancelled = super.cancel(mayInterruptIfRunning);
  // & is faster than the branch required for &&
  if (cancelled & futures != null) {
    for (ListenableFuture<?> future : futures) {
      future.cancel(mayInterruptIfRunning);
    }
  }
  return cancelled;
}
项目:copybara    文件:RestoreOriginalAuthor.java   
@Override
public void transform(TransformWork work)
    throws IOException, ValidationException {
  Author author = null;
  // If multiple commits are included (for example on a squash for skipping a bad change),
  // last author wins.
  for (Change<?> change : work.getChanges().getCurrent()) {
    ImmutableCollection<String> labelValue = change.getLabels().get(label);
    if (!labelValue.isEmpty()) {
      try {
        author = Author.parse(/*location=*/null, Iterables.getLast(labelValue));
      } catch (EvalException e) {
        // Don't fail the migration because the label is wrong since it is very
        // difficult for a user to recover from this.
        work.getConsole().warn("Cannot restore original author: " + e.getMessage());
      }
    }
    if (!searchAllChanges) {
      break;
    }
  }
  if (author != null) {
    work.setAuthor(author);
    work.removeLabel(label, /*wholeMessage=*/true);
  }
}
项目:copybara    文件:ChangeVisitable.java   
/**
 * Visit only changes that contain any of the labels in {@code labels}.
 */
default void visitChangesWithAnyLabel(
    R start, ImmutableCollection<String> labels, ChangesLabelVisitor visitor)
    throws RepoException, ValidationException {
  visitChanges(start, input -> {
    // We could return all the label values, but this is really only used for
    // RevId like ones and last is good enough for now.
    Map<String, String> copy = Maps.newHashMap(Maps.transformValues(input.getLabels().asMap(),
        Iterables::getLast));
    copy.keySet().retainAll(labels);
    if (copy.isEmpty()) {
      return VisitResult.CONTINUE;
    }
    return visitor.visit(input, ImmutableMap.copyOf(copy));
  });
}
项目:nomulus    文件:IcannReportingStager.java   
/** Creates and stores activity reports on GCS, returns a list of files stored. */
private ImmutableList<String> stageActivityReports(
    String headerRow, ImmutableCollection<Map<TableFieldSchema, Object>> rows)
    throws IOException {
  ImmutableList.Builder<String> manifestBuilder = new ImmutableList.Builder<>();
  // Create a report csv for each tld from query table, and upload to GCS
  for (Map<TableFieldSchema, Object> row : rows) {
    // Get the tld (first cell in each row)
    String tld = row.values().iterator().next().toString();
    if (isNullOrEmpty(tld)) {
      throw new RuntimeException("Found an empty row in the activity report table!");
    }
    ImmutableList<String> rowStrings = ImmutableList.of(constructRow(row.values()));
    // Create and upload the activity report with a single row
    manifestBuilder.add(
        saveReportToGcs(tld, createReport(headerRow, rowStrings), ReportType.ACTIVITY));
  }
  return manifestBuilder.build();
}
项目:GitHub    文件:ModifiablesTest.java   
@Test
@SuppressWarnings("deprecation")
public void modifiableImmutableCollections() {
  ModifiableMutableImmutableCollection m = ModifiableMutableImmutableCollection.create();
  m.addA("a");
  m.addA("b", "c");
  m.addB("d", "e");
  m.putC("x", 1);
  m.putC("y", 2);

  check(m.a()).isA(ImmutableCollection.class);
  check(m.b()).isA(ImmutableCollection.class);
  check(m.c()).isA(ImmutableMultimap.class);
  check(m.d()).isA(ImmutableMap.class);

  check(m.a()).isOf("a", "b", "c");
  check(m.b()).isOf("d", "e");

  check(m.c().values()).isOf(1, 2);
  check(m.c().keySet()).isOf("x", "y");

  check(m.d().isEmpty());

  m.clear();

  check(m.a()).isEmpty();
  check(m.b()).isEmpty();
  check(m.c().entries()).isEmpty();
  check(m.d().entrySet()).isEmpty();
}
项目:guava-mock    文件:AggregateFuture.java   
RunningState(
    ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures,
    boolean allMustSucceed,
    boolean collectsValues) {
  super(futures.size());
  this.futures = checkNotNull(futures);
  this.allMustSucceed = allMustSucceed;
  this.collectsValues = collectsValues;
}
项目:guava-mock    文件:CollectionFuture.java   
CollectionFutureRunningState(
    ImmutableCollection<? extends ListenableFuture<? extends V>> futures,
    boolean allMustSucceed) {
  super(futures, allMustSucceed, true);

  this.values =
      futures.isEmpty()
          ? ImmutableList.<Optional<V>>of()
          : Lists.<Optional<V>>newArrayListWithCapacity(futures.size());

  // Populate the results list with null initially.
  for (int i = 0; i < futures.size(); ++i) {
    values.add(null);
  }
}
项目:guava-mock    文件:CombinedFuture.java   
CombinedFuture(
    ImmutableCollection<? extends ListenableFuture<?>> futures,
    boolean allMustSucceed,
    Executor listenerExecutor,
    AsyncCallable<V> callable) {
  init(
      new CombinedFutureRunningState(
          futures,
          allMustSucceed,
          new AsyncCallableInterruptibleTask(callable, listenerExecutor)));
}
项目:guava-mock    文件:CombinedFuture.java   
CombinedFuture(
    ImmutableCollection<? extends ListenableFuture<?>> futures,
    boolean allMustSucceed,
    Executor listenerExecutor,
    Callable<V> callable) {
  init(
      new CombinedFutureRunningState(
          futures, allMustSucceed, new CallableInterruptibleTask(callable, listenerExecutor)));
}
项目:guava-mock    文件:CombinedFuture.java   
CombinedFutureRunningState(
    ImmutableCollection<? extends ListenableFuture<? extends Object>> futures,
    boolean allMustSucceed,
    CombinedFutureInterruptibleTask task) {
  super(futures, allMustSucceed, false);
  this.task = task;
}
项目:ProjectAres    文件:IterableUtils.java   
/**
 * Return a copy of the given collection in whatever subclass of {@link ImmutableCollection} fits best
 */
public static <E> ImmutableCollection<E> immutableCopyOf(Collection<E> things) {
    if(things instanceof List) {
        return ImmutableList.copyOf(things);
    } else {
        return ImmutableSet.copyOf(things);
    }
}
项目:ProjectAres    文件:IterableUtils.java   
public static <T> ImmutableCollection<T> copyOf(Iterable<T> iterable) {
    if(iterable instanceof Set) {
        return ImmutableSet.copyOf(iterable);
    } else if(iterable instanceof Multiset) {
        return ImmutableMultiset.copyOf(iterable);
    } else {
        return ImmutableList.copyOf(iterable);
    }
}
项目:NullAway    文件:LibraryModels.java   
@Nullable
private static Symbol.MethodSymbol methodInSet(
    Symbol.MethodSymbol symbol, Types types, ImmutableCollection<MethodRef> memberNames) {
  if (memberNames.contains(MethodRef.fromSymbol(symbol))) {
    return symbol;
  }
  for (Symbol.MethodSymbol superSymbol : ASTHelpers.findSuperMethods(symbol, types)) {
    if (memberNames.contains(MethodRef.fromSymbol(superSymbol))) {
      return superSymbol;
    }
  }
  return null;
}
项目:dotwebstack-framework    文件:AbstractFunctionTest.java   
protected ImmutableCollection<Object> evaluateRule(final String ldPath, IRI context)
    throws ParseException {
  final LdPathParser<Value> parser = createParserFromString(ldPath);
  final FieldMapping<Object, Value> rule = parser.parseRule(NAMESPACES);

  return ImmutableList.copyOf(rule.getValues(backend, context));
}
项目:dotwebstack-framework    文件:KeepAfterLastFunctionTest.java   
@Test
public void testKeepAfterLastFunction() throws ParseException {
  final String id = "baz";
  final String ldPath =
      String.format("fn:keepAfterLast(<%s>, \"%s\") :: xsd:string", predicate.stringValue(), "/");
  addStatement(repository.getValueFactory().createStatement(subject, predicate, iri("ex", id)));

  final ImmutableCollection<Object> values = evaluateRule(ldPath, subject);

  assertThat(values.size(), Matchers.equalTo(1));
  assertThat(values, Matchers.contains("example.com#baz"));
}
项目:dotwebstack-framework    文件:KeepAfterLastFunctionTest.java   
@Test
public void testNoOccurrence() throws ParseException {
  final String value = "stringLiteral";
  final String ldPath =
      String.format("fn:keepAfterLast(<%s>, \"%s\") :: xsd:string", predicate.stringValue(), "/");
  addStatement(repository.getValueFactory().createStatement(subject, predicate,
      repository.getValueFactory().createLiteral(value)));

  final ImmutableCollection<Object> values = evaluateRule(ldPath, subject);

  assertThat(values.size(), Matchers.equalTo(1));
  assertThat(values, Matchers.contains(value));
}
项目:Equella    文件:EditableCtrl.java   
public ImmutableCollection<String> getValues()
{
    synchronized( valuesLock )
    {
        return ImmutableList.copyOf(values);
    }
}
项目:javaide    文件:JavaInput.java   
/**
 * Convert from an offset and length flag pair to a token range.
 *
 * @param offset the {@code 0}-based offset in characters
 * @param length the length in characters
 * @return the {@code 0}-based {@link Range} of tokens
 * @throws FormatterException
 */
Range<Integer> characterRangeToTokenRange(int offset, int length) throws FormatterException {
    int requiredLength = offset + length;
    if (requiredLength > text.length()) {
        throw new FormatterException(
                String.format(
                        "error: invalid length %d, offset + length (%d) is outside the file",
                        length, requiredLength));
    }
    if (length < 0) {
        return EMPTY_RANGE;
    }
    if (length == 0) {
        // 0 stands for "format the line under the cursor"
        length = 1;
    }
    ImmutableCollection<Token> enclosed =
            getPositionTokenMap()
                    .subRangeMap(Range.closedOpen(offset, offset + length))
                    .asMapOfRanges()
                    .values();
    if (enclosed.isEmpty()) {
        return EMPTY_RANGE;
    }
    return Range.closedOpen(
            enclosed.iterator().next().getTok().getIndex(), getLast(enclosed).getTok().getIndex() + 1);
}
项目:googles-monorepo-demo    文件:AggregateFuture.java   
RunningState(
    ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures,
    boolean allMustSucceed,
    boolean collectsValues) {
  super(futures.size());
  this.futures = checkNotNull(futures);
  this.allMustSucceed = allMustSucceed;
  this.collectsValues = collectsValues;
}