本文整理汇总了Java中com.google.common.collect.ImmutableList.size方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableList.size方法的具体用法?Java ImmutableList.size怎么用?Java ImmutableList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableList
的用法示例。
在下文中一共展示了ImmutableList.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParametersForSignature
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
/**
* Returns an array containing parameters for invoking a checkArgument, checkNotNull or checkState
* method reflectively
*
* @param firstParam The first parameter
* @param sig The method signature
*/
@GwtIncompatible("ArbitraryInstances")
private Object[] getParametersForSignature(Object firstParam, ImmutableList<Class<?>> sig) {
Object[] params = new Object[sig.size()];
params[0] = firstParam;
if (params.length > 1) {
params[1] = "";
if (params.length > 2) {
// fill in the rest of the array with arbitrary instances
for (int i = 2; i < params.length; i++) {
params[i] = ArbitraryInstances.get(sig.get(i));
}
}
}
return params;
}
示例2: getNonnullReceiverFields
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private Set<Element> getNonnullReceiverFields(NullnessStore<Nullness> nullnessResult) {
Set<AccessPath> nonnullAccessPaths = nullnessResult.getAccessPathsWithValue(Nullness.NONNULL);
Set<Element> result = new LinkedHashSet<>();
for (AccessPath ap : nonnullAccessPaths) {
if (ap.getRoot().isReceiver()) {
ImmutableList<Element> elements = ap.getElements();
if (elements.size() == 1) {
Element elem = elements.get(0);
if (elem.getKind().equals(ElementKind.FIELD)) {
result.add(elem);
}
}
}
}
return result;
}
示例3: test
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
public void test() {
for (int groupNumber = 0; groupNumber < groups.size(); groupNumber++) {
ImmutableList<T> group = groups.get(groupNumber);
for (int itemNumber = 0; itemNumber < group.size(); itemNumber++) {
// check related items in same group
for (int relatedItemNumber = 0; relatedItemNumber < group.size(); relatedItemNumber++) {
if (itemNumber != relatedItemNumber) {
assertRelated(groupNumber, itemNumber, relatedItemNumber);
}
}
// check unrelated items in all other groups
for (int unrelatedGroupNumber = 0; unrelatedGroupNumber < groups.size();
unrelatedGroupNumber++) {
if (groupNumber != unrelatedGroupNumber) {
ImmutableList<T> unrelatedGroup = groups.get(unrelatedGroupNumber);
for (int unrelatedItemNumber = 0; unrelatedItemNumber < unrelatedGroup.size();
unrelatedItemNumber++) {
assertUnrelated(groupNumber, itemNumber, unrelatedGroupNumber, unrelatedItemNumber);
}
}
}
}
}
}
示例4: runTests
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private static void runTests(
AuthorityClassifier p,
ImmutableMap<Classification, ImmutableList<String>> inputs) {
Diagnostic.CollectingReceiver<UrlValue> cr = Diagnostic.CollectingReceiver.from(
TestUtil.STDERR_RECEIVER);
try {
for (Map.Entry<Classification, ImmutableList<String>> e
: inputs.entrySet()) {
Classification want = e.getKey();
ImmutableList<String> inputList = e.getValue();
for (int i = 0; i < inputList.size(); ++i) {
cr.clear();
String url = inputList.get(i);
UrlValue inp = UrlValue.from(TEST_URL_CONTEXT, url);
Classification got = p.apply(inp, cr);
assertEquals(i + ": " + url, want, got);
}
cr.clear();
}
} finally {
cr.flush();
}
}
示例5: write
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
public void write(Encoder encoder, ImmutableList<TaskExecutionSnapshot> value) throws Exception {
int size = value.size();
encoder.writeByte((byte) size);
LazyTaskExecution.TaskExecutionSnapshotSerializer executionSerializer = new LazyTaskExecution.TaskExecutionSnapshotSerializer(getClassLoader(), stringInterner);
for (TaskExecutionSnapshot execution : value) {
executionSerializer.write(encoder, execution);
}
}
示例6: MultiModelState
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
public <M extends IModel, S extends IModelState> MultiModelState(ImmutableList<Pair<M, S>> states)
{
ImmutableMap.Builder<MultiModelPart, S> builder = ImmutableMap.builder();
for(int i = 0; i < states.size(); i++)
{
Pair<M, S> pair = states.get(i);
builder.put(new MultiModelPart(pair.getLeft(), i), pair.getRight());
}
this.states = builder.build();
}
示例7: visitFunctionHolderExpression
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
public Void visitFunctionHolderExpression(FunctionHolderExpression holder, StringBuilder sb) throws RuntimeException {
ImmutableList<LogicalExpression> args = holder.args;
sb.append(holder.getName());
sb.append("(");
for (int i = 0; i < args.size(); i++) {
if (i != 0) {
sb.append(", ");
}
args.get(i).accept(this, sb);
}
sb.append(") ");
return null;
}
示例8: toBoundAccessExpression
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
public BoundAccessExpression toBoundAccessExpression(BoundAccessExpression value) {
ImmutableList<Accessors.BoundAccess> accessList = TypeResolver.asBoundAccess(value.accessor());
StringBuilder expressionBuilder = new StringBuilder();
for (int i = 0; i < accessList.size(); i++) {
boolean first = i == 0;
boolean last = i != accessList.size() - 1;
Accessors.BoundAccess access = accessList.get(i);
if (!first) {
expressionBuilder.append(".");
}
String name = access.name;
if (first) {
name = context.accessMapper(name);
}
expressionBuilder.append(name).append(access.callable ? "()" : "");
if (access.boxed && last) {
expressionBuilder.insert(0, "$(");
expressionBuilder.append(")");
}
}
context.out(expressionBuilder);
return value;
}
示例9: findMetricPointForLabels
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private @Nullable MetricPoint<T> findMetricPointForLabels(ImmutableList<String> labels) {
if (actual().getMetricSchema().labels().size() != labels.size()) {
return null;
}
for (MetricPoint<T> metricPoint : actual().getTimestampedValues()) {
if (metricPoint.labelValues().equals(labels)) {
return metricPoint;
}
}
return null;
}
示例10: findDataBinding
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private Optional<Element> findDataBinding(final Set<? extends Element> rootElements) {
List<Element> bindingCandidates = new ArrayList<>();
for (Element element : rootElements) {
TypeMirror typeMirror = element.asType();
List<? extends TypeMirror> supertypes = typeUtils.directSupertypes(typeMirror);
if (!Collections2.filter(supertypes, Predicates.IS_VIEW_DATA_BINDING).isEmpty()) {
List<ExecutableElement> executableElements = ElementFilter.methodsIn(element.getEnclosedElements());
ImmutableList<ExecutableElement> setVariableMethod = FluentIterable.from(executableElements)
.filter(Predicates.IS_VOID_METHOD)
.filter(Predicates.HAS_ONE_PARAMETER)
.filter(Predicates.STARTS_WITH_SET)
.toList();
boolean hasSetMethodForModel = Collections2.filter(setVariableMethod,
Predicates.parameterIsSameType(model)).size() == 1;
if (hasSetMethodForModel && setVariableMethod.size() > 1) {
messager.printMessage(Diagnostic.Kind.WARNING,
"ViewDataBinding for " + model.getSimpleName() + " has more than one variable.", model);
return Optional.absent();
} else if (hasSetMethodForModel) {
bindingCandidates.add(element);
}
}
}
if (bindingCandidates.size() == 1) {
return Optional.of(bindingCandidates.get(0));
} else if (bindingCandidates.size() > 1) {
messager.printMessage(Diagnostic.Kind.WARNING,
"There is more than one ViewDataBinding for " + model.getSimpleName(), model);
}
return Optional.absent();
}
示例11: getSimilarClauses
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends CypherClause> List<T> getSimilarClauses(ImmutableList<CypherClause> clauses, int clauseIndex, Class<T> clazz) {
List<T> matchClauses = new ArrayList<T>();
matchClauses.add((T) clauses.get(clauseIndex));
while (clauseIndex + 1 < clauses.size() && clazz.isInstance(clauses.get(clauseIndex + 1))) {
matchClauses.add((T) clauses.get(clauseIndex + 1));
clauseIndex++;
}
return matchClauses;
}
示例12: findList
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
default <T> ImmutableList<T> findList(Function<Either<Object, ? extends PropertyTree>,Maybe<T>> map, Iterable<String> path) {
Iterator<String> iterator = path.iterator();
Preconditions.checkArgument(iterator.hasNext(),"empty path: %s",path);
Maybe<PropertyTree> current = Maybe.of(this);
while (current.isPresent() && iterator.hasNext()) {
String key=iterator.next();
List<Either<Object, ? extends PropertyTree>> list = current.get().get(key);
if (!iterator.hasNext()) {
ImmutableList<T> result = list.stream().map(map).filter(Maybe::isPresent).map(Maybe::get).collect(ImmutableList.toImmutableList());
if (result.size()==list.size()) {
return result;
} else {
return ImmutableList.of();
}
} else {
if (list.size()==1) {
Either<Object, ? extends PropertyTree> value = list.get(0);
if (!value.isLeft()) {
current=Maybe.of(value.right());
} else {
return ImmutableList.of();
}
} else {
return ImmutableList.of();
}
}
}
return ImmutableList.of();
}
示例13: peekToken
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
/**
* Return the text of the next {@link Token}, or absent if there is none.
*/
public final Optional<String> peekToken() {
ImmutableList<? extends Token> tokens = input.getTokens();
return tokenI < tokens.size()
? Optional.of(tokens.get(tokenI).getTok().getOriginalText())
: Optional.<String>absent();
}
示例14: listBooks
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
public synchronized void listBooks(
ListBooksRequest request, StreamObserver<ListBooksResponse> responseObserver) {
NavigableMap<String, Book> cursor = booksById;
// Resume iteration from the page token.
if (!request.getPageToken().isEmpty()) {
String pageToken = decodePageToken(request.getPageToken());
cursor = cursor.tailMap(pageToken, false);
}
ImmutableList<Book> books =
cursor
.values()
.stream()
.limit(request.getPageSize() > 0 ? request.getPageSize() : DEFAULT_PAGE_SIZE)
.collect(ImmutableList.toImmutableList());
// Return one page of results.
ListBooksResponse.Builder responseBuilder = ListBooksResponse.newBuilder().addAllBooks(books);
// Set next page token to resume iteration in the next request.
if (cursor.values().size() > books.size()) {
String nextPageToken = encodePageToken(books.get(books.size() - 1).getId());
responseBuilder.setNextPageToken(nextPageToken);
}
responseObserver.onNext(responseBuilder.build());
responseObserver.onCompleted();
}
示例15: find
import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
default <T> Maybe<T> find(Function<Either<Object, ? extends PropertyTree>,Maybe<T>> map, Iterable<String> path) {
ImmutableList<T> result = findList(map, path);
return result.size()==1
? Maybe.of(result.get(0))
: Maybe.empty();
}