java类com.google.common.collect.ImmutableCollection的实例源码

CombinedFuture.java 文件源码 项目:guava-mock 阅读 45 收藏 0 点赞 0 评论 0
CombinedFutureRunningState(
    ImmutableCollection<? extends ListenableFuture<? extends Object>> futures,
    boolean allMustSucceed,
    CombinedFutureInterruptibleTask task) {
  super(futures, allMustSucceed, false);
  this.task = task;
}
IterableUtils.java 文件源码 项目:ProjectAres 阅读 38 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
IterableUtils.java 文件源码 项目:ProjectAres 阅读 32 收藏 0 点赞 0 评论 0
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);
    }
}
LibraryModels.java 文件源码 项目:NullAway 阅读 30 收藏 0 点赞 0 评论 0
@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;
}
AbstractFunctionTest.java 文件源码 项目:dotwebstack-framework 阅读 26 收藏 0 点赞 0 评论 0
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));
}
KeepAfterLastFunctionTest.java 文件源码 项目:dotwebstack-framework 阅读 32 收藏 0 点赞 0 评论 0
@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"));
}
KeepAfterLastFunctionTest.java 文件源码 项目:dotwebstack-framework 阅读 34 收藏 0 点赞 0 评论 0
@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));
}
EditableCtrl.java 文件源码 项目:Equella 阅读 21 收藏 0 点赞 0 评论 0
public ImmutableCollection<String> getValues()
{
    synchronized( valuesLock )
    {
        return ImmutableList.copyOf(values);
    }
}
JavaInput.java 文件源码 项目:javaide 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 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);
}
AggregateFuture.java 文件源码 项目:googles-monorepo-demo 阅读 38 收藏 0 点赞 0 评论 0
RunningState(
    ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures,
    boolean allMustSucceed,
    boolean collectsValues) {
  super(futures.size());
  this.futures = checkNotNull(futures);
  this.allMustSucceed = allMustSucceed;
  this.collectsValues = collectsValues;
}


问题


面经


文章

微信
公众号

扫码关注公众号