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.xlrnet.tibaija.processor.Command.java

/**
 * Checks the passed arguments for correctness. This method should be called only by the framework.
 *
 * @param arguments/*from w ww.ja  va 2  s.com*/
 *         The arguments to check
 * @return True if number and values of the arguments are correct. Execute() may use the arguments afterwards
 * unchecked. <br> False if the number is below or above excepted range or if any value is incorrect.
 * @throws TIArgumentException
 *         Will be thrown if either the count or the value of any argument is invalid.
 */
protected final boolean checkArguments(@NotNull ImmutableList<Parameter> arguments) throws TIArgumentException {
    if (!hasValidNumberOfArguments(arguments.size())) {
        throw new TIArgumentException("Invalid argument count", arguments);
    }
    if (!hasValidArgumentValues(arguments)) {
        throw new TIArgumentException("Invalid argument value", arguments);
    }

    return true;
}

From source file:com.facebook.buck.file.downloader.impl.StackedDownloader.java

@VisibleForTesting
StackedDownloader(ImmutableList<Downloader> delegates) {
    Preconditions.checkArgument(delegates.size() > 0);
    this.delegates = delegates;
}

From source file:org.caleydo.view.bicluster.sorting.FuzzyClustering.java

public ImmutableList<IntFloat> positives(float threshold, int maxElements) {
    ImmutableSortedSet<IntFloat> r = memberships.tailSet(new IntFloat(Integer.MIN_VALUE, Math.abs(threshold)),
            true);/*from w w w  . j  a  v  a 2  s . c o  m*/
    ImmutableList<IntFloat> l = r.asList();

    if (l.size() <= maxElements || maxElements == UNBOUND_NUMBER)
        return l;
    // the lower the index the nearer to zero to less interesting
    return l.subList(l.size() - maxElements, l.size());
}

From source file:org.caleydo.view.bicluster.sorting.FuzzyClustering.java

public ImmutableList<IntFloat> negatives(float threshold, int maxElements) {
    ImmutableSortedSet<IntFloat> r = memberships.headSet(new IntFloat(Integer.MAX_VALUE, -Math.abs(threshold)),
            true);//from www  .  j  a va2  s. c  om
    ImmutableList<IntFloat> l = r.asList();

    if (l.size() <= maxElements || maxElements == UNBOUND_NUMBER)
        return l;
    // the larger the index the nearer to zero to less interesting
    return l.subList(0, maxElements);

}

From source file:com.google.testing.i18n.sanitycheck.checkers.OrderingChecker.java

@Override
protected void makeCheck(Placeholder target, ImmutableList<String> tokenizedInput, ULocale locale,
        String message) {/*from  ww  w.  j a v  a  2s . c o m*/
    if (tokenizedInput.size() < 2) {
        // Test passed. Nothing to sort.
        return;
    }

    int strength = Collator.SECONDARY;
    if (!target.isLenient()) {
        if (!target.isStrict()) {
            strength = Collator.TERTIARY;
        } else {
            strength = Collator.IDENTICAL;
        }
    }
    // Init collators.
    Collator collator = Collator.getInstance(locale);
    ImmutableList.Builder<Collator> collators = ImmutableList.builder();
    collators.add(collator);
    try {
        Collator collator2 = (RuleBasedCollator) collator.clone();
        collator2.setStrength(strength);
        collators.add(collator2);
        RuleBasedCollator collator3 = (RuleBasedCollator) collator.clone();
        collator3.setStrength(strength);
        collator3.setAlternateHandlingShifted(true);
        collators.add(collator3);
        RuleBasedCollator collator4 = (RuleBasedCollator) collator.clone();
        collator4.setStrength(strength);
        collator4.setNumericCollation(true);
        collators.add(collator4);
        RuleBasedCollator collator5 = (RuleBasedCollator) collator.clone();
        collator5.setStrength(strength);
        collator5.setAlternateHandlingShifted(true);
        collator5.setNumericCollation(true);
        collators.add(collator5);
    } catch (CloneNotSupportedException e) {
        // Do nothing.
    }
    makeCheck(collators.build(), tokenizedInput, locale, message);
}

From source file:org.waveprotocol.box.server.persistence.blocks.impl.SegmentOperationImpl.java

@Override
public long getTargetVersion() {
    ImmutableList<? extends WaveletOperation> ops = rawOperation.getOperations();
    return ops.get(ops.size() - 1).getContext().getSegmentVersion();
}

From source file:org.waveprotocol.box.server.persistence.blocks.impl.SegmentOperationImpl.java

@Override
public long getTimestamp() {
    ImmutableList<? extends WaveletOperation> ops = rawOperation.getOperations();
    return ops.get(ops.size() - 1).getContext().getTimestamp();
}

From source file:org.geogit.cli.plumbing.RebuildGraph.java

@Override
public void runInternal(GeogitCLI cli) throws IOException {
    ImmutableList<ObjectId> updatedObjects = cli.getGeogit().command(RebuildGraphOp.class).call();

    final ConsoleReader console = cli.getConsole();
    if (updatedObjects.size() > 0) {
        if (quiet) {
            console.println(updatedObjects.size() + " graph elements (commits) were fixed.");
        } else {//  w  w w . j  a v  a  2s.com
            console.println(
                    "The following graph elements (commits) were incomplete or missing and have been fixed:");
            for (ObjectId object : updatedObjects) {
                console.println(object.toString());
            }
        }
    } else {
        console.println("No missing or incomplete graph elements (commits) were found.");
    }
}

From source file:com.google.cloud.bigtable.grpc.scanner.SimpleRowConverter.java

public Row.Builder buildRow(SimpleRow row) {
    Row.Builder rowBuilder = Row.newBuilder();
    String prevKey = "";
    Family.Builder familyBuilder = null;
    ImmutableList<SimpleColumn> list = SimpleRow.FamilyColumnOrdering.DEFAULT_ORDERING
            .immutableSortedCopy(row.getList());

    for (int i = 0; i < list.size(); i++) {
        SimpleColumn column = list.get(i);
        if (!prevKey.equals(column.getFamily())) {
            familyBuilder = rowBuilder.addFamiliesBuilder().setName(column.getFamily());
        }//from w  ww  .j a  v  a2s.c o  m
        Column.Builder columnBuilder = Column.newBuilder().setQualifier(column.getQualifier());
        columnBuilder.addCells(Cell.newBuilder().setTimestampMicros(column.getTimestamp())
                .addAllLabels(column.getLabels()).setValue(column.getValue()).build());
        familyBuilder.addColumns(columnBuilder);
        prevKey = column.getFamily();
    }
    return rowBuilder;
}

From source file:org.locationtech.geogig.cli.plumbing.RebuildGraph.java

@Override
public void runInternal(GeogigCLI cli) throws IOException {
    ImmutableList<ObjectId> updatedObjects = cli.getGeogig().command(RebuildGraphOp.class).call();

    final ConsoleReader console = cli.getConsole();
    if (updatedObjects.size() > 0) {
        if (quiet) {
            console.println(updatedObjects.size() + " graph elements (commits) were fixed.");
        } else {//from w w w . ja va  2 s.c o  m
            console.println(
                    "The following graph elements (commits) were incomplete or missing and have been fixed:");
            for (ObjectId object : updatedObjects) {
                console.println(object.toString());
            }
        }
    } else {
        console.println("No missing or incomplete graph elements (commits) were found.");
    }
}