Example usage for com.google.common.collect ImmutableList size

List of usage examples for com.google.common.collect ImmutableList size

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this list.

Usage

From source file:org.eclipse.buildship.ui.view.task.WorkbenchSelectionListener.java

private void selectProjectsInTree(List<IProject> projects) {
    Builder<TreeItem> selection = ImmutableList.builder();

    Tree tree = this.taskView.getTreeViewer().getTree();
    for (TreeItem treeItem : tree.getItems()) {
        Object data = treeItem.getData();
        if (data instanceof BaseProjectNode) {
            BaseProjectNode selectedNode = (BaseProjectNode) data;
            Optional<IProject> workspaceProject = selectedNode.getWorkspaceProject();
            if (workspaceProject.isPresent() && projects.contains(workspaceProject.get())) {
                selection.add(treeItem);
            }/*from w ww . j a v a2 s  .  c o  m*/
        }
    }

    ImmutableList<TreeItem> treeSelection = selection.build();
    tree.setSelection(treeSelection.toArray(new TreeItem[treeSelection.size()]));
}

From source file:com.github.explainable.sql.ast.expression.SqlSubSelect.java

@Nullable
@Override//from  w  w  w.  j  a v a  2 s .  com
public EqualityArg equalityArg() {
    if (select instanceof SqlPlainSelect) {
        ImmutableList<SqlSelectItem> items = ((SqlPlainSelect) select).selectItems().itemList();

        if (items.size() == 1) {
            SqlSelectItem item = items.get(0);

            if (item instanceof SqlSelectColumn) {
                return ((SqlSelectColumn) item).value().equalityArg();
            }
        }
    }

    return null;
}

From source file:dagger.internal.codegen.MapFactoryCreationExpression.java

@Override
public CodeBlock creationExpression() {
    CodeBlock.Builder builder = CodeBlock.builder().add("$T.", mapFactoryClassName(binding));
    if (!useRawType()) {
        MapType mapType = MapType.from(binding.key().type());
        // TODO(ronshapiro): either inline this into mapFactoryClassName, or add a
        // mapType.unwrappedValueType() method that doesn't require a framework type
        TypeMirror valueType = mapType.valueType();
        for (Class<?> frameworkClass : ImmutableSet.of(Provider.class, Producer.class, Produced.class)) {
            if (mapType.valuesAreTypeOf(frameworkClass)) {
                valueType = mapType.unwrappedValueType(frameworkClass);
                break;
            }//from  ww w . j  a  v  a2 s.  co  m
        }
        builder.add("<$T, $T>", mapType.keyType(), valueType);
    }

    ImmutableList<FrameworkDependency> frameworkDependencies = binding.frameworkDependencies();
    builder.add("builder($L)", frameworkDependencies.size());

    superContributions().ifPresent(superContributions -> builder.add(".putAll($L)", superContributions));

    for (FrameworkDependency frameworkDependency : frameworkDependenciesToImplement()) {
        ContributionBinding contributionBinding = graph.contributionBindings().get(frameworkDependency.key())
                .contributionBinding();
        builder.add(".put($L, $L)",
                getMapKeyExpression(contributionBinding, componentImplementation.name(), elements),
                multibindingDependencyExpression(frameworkDependency));
    }
    builder.add(".build()");

    componentImplementation.registerImplementedMultibinding(binding, bindingRequest());

    return builder.build();
}

From source file:com.google.devtools.build.docgen.RuleFamily.java

RuleFamily(ListMultimap<RuleType, RuleDocumentation> ruleTypeMap, String name) {
    this.name = name;
    this.id = normalize(name);
    this.binaryRules = ImmutableList.copyOf(ruleTypeMap.get(RuleType.BINARY));
    this.libraryRules = ImmutableList.copyOf(ruleTypeMap.get(RuleType.LIBRARY));
    this.testRules = ImmutableList.copyOf(ruleTypeMap.get(RuleType.TEST));

    final ImmutableList<RuleDocumentation> otherRules = ImmutableList.copyOf(ruleTypeMap.get(RuleType.OTHER));
    if (otherRules.size() >= 4) {
        this.otherRules1 = ImmutableList.copyOf(otherRules.subList(0, otherRules.size() / 2));
        this.otherRules2 = ImmutableList.copyOf(otherRules.subList(otherRules.size() / 2, otherRules.size()));
    } else {//from  w  ww  .j av  a2  s.com
        this.otherRules1 = otherRules;
        this.otherRules2 = ImmutableList.of();
    }

    rules = ImmutableList.<RuleDocumentation>builder().addAll(binaryRules).addAll(libraryRules)
            .addAll(testRules).addAll(otherRules1).addAll(otherRules2).build();
}

From source file:com.google.template.soy.jbcsrc.restricted.BytecodeUtils.java

private static Expression doShortCircuitingLogicalOperator(
        final ImmutableList<? extends Expression> expressions, final boolean isOrOperator) {
    checkArgument(!expressions.isEmpty());
    for (Expression expr : expressions) {
        expr.checkAssignableTo(Type.BOOLEAN_TYPE);
    }/*  www  .ja va 2 s.  c  o  m*/
    if (expressions.size() == 1) {
        return expressions.get(0);
    }

    return new Expression(Type.BOOLEAN_TYPE,
            Expression.areAllCheap(expressions) ? Features.of(Feature.CHEAP) : Features.of()) {
        @Override
        protected void doGen(CodeBuilder adapter) {
            Label end = new Label();
            Label shortCircuit = new Label();
            for (int i = 0; i < expressions.size(); i++) {
                Expression expr = expressions.get(i);
                expr.gen(adapter);
                if (i == expressions.size() - 1) {
                    // if we are the last one, just goto end. Whatever the result of the last expression is
                    // determines the result of the whole expression (when all prior tests fail).
                    adapter.goTo(end);
                } else {
                    adapter.ifZCmp(isOrOperator ? Opcodes.IFNE : Opcodes.IFEQ, shortCircuit);
                }
            }
            adapter.mark(shortCircuit);
            adapter.pushBoolean(isOrOperator); // default for || is true && is false
            adapter.mark(end);
        }
    };
}

From source file:org.nmdp.service.epitope.service.EpitopeServiceImpl.java

/**
 * {@inheritDoc}//from w ww.  j ava 2 s.c  o  m
 */
@Override
public Integer getGroupForAllele(Allele allele) {
    ImmutableList<Integer> list = alleleGroupMap.get(allele);
    if (list.size() == 0)
        return null; // throw new RuntimeException("no group for allele: " + allele);
    return list.get(0);
}

From source file:com.facebook.buck.rules.coercer.ZeroArgMacroTypeCoercer.java

@Override
public M coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot,
        TargetConfiguration targetConfiguration, ImmutableList<String> args) throws CoerceFailedException {
    if (!args.isEmpty()) {
        throw new CoerceFailedException(String.format("expected zero arguments (found %d)", args.size()));
    }/* w w  w.  j  a  va 2s .c  om*/
    return val;
}

From source file:fr.inria.maestro.lga.clustering.impl.ClusteringImpl.java

/**
 * Creates classification.// ww  w.  j  a v a 2  s .c  o  m
 * @param name - the name of classification.
 * @param clusters - the list of classes.
 */
public ClusteringImpl(final String name, final ImmutableList<ICluster> clusters) {
    this.name = name;
    this.clusters = clusters;

    final Set<String> clusterNames = Sets.newHashSetWithExpectedSize(clusters.size());
    for (final ICluster cluster : clusters) {
        clusterNames.add(cluster.getName());
    }
}

From source file:ch.acanda.eclipse.pmd.java.resolution.PMDMarkerResolutionGenerator.java

@Override
public IMarkerResolution[] getResolutions(final IMarker marker) {
    final JavaQuickFixContext context = new JavaQuickFixContext(getCompilerCompliance(marker));
    final ImmutableList<IMarkerResolution> quickFixes = quickFixGenerator
            .getQuickFixes(new WrappingPMDMarker(marker), context);
    return quickFixes.toArray(new IMarkerResolution[quickFixes.size()]);
}

From source file:com.facebook.buck.apple.xcode.xcconfig.TokenValue.java

public TokenValue interpolate(Function<String, Optional<TokenValue>> function) {
    switch (type) {
    case LITERAL:
        return this;

    case INTERPOLATION:
        ImmutableList<TokenValue> newValue = interpolateList(function, interpolationValue);
        if (newValue.size() == 1 && newValue.get(0).type == Type.LITERAL) {
            Optional<TokenValue> interpolated = function.apply(newValue.get(0).literalValue);
            if (interpolated.isPresent()) {
                return interpolated.get();
            }/*w w  w .  jav  a 2 s .  com*/
        }
        return interpolation(newValue);
    }
    // unreachable
    throw new IllegalStateException("'type' should always be of type 'LITERAL' or 'INTERPOLATION'");
}