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:com.google.template.soy.jssrc.dsl.ConditionalBuilder.java

private boolean isRepresentableAsTernaryExpression(ImmutableList<IfThenPair> pairs) {
    if (pairs.size() != 1 || trailingElse == null) {
        return false;
    }/*from www.  j  a  v  a 2  s . co m*/

    IfThenPair ifThen = Iterables.getOnlyElement(pairs);
    CodeChunk.WithValue predicate = ifThen.predicate;
    CodeChunk consequent = ifThen.consequent;
    return consequent instanceof CodeChunk.WithValue && trailingElse instanceof CodeChunk.WithValue
            && predicate.initialStatements().containsAll(((WithValue) consequent).initialStatements())
            && predicate.initialStatements().containsAll(((WithValue) trailingElse).initialStatements());
}

From source file:org.spongepowered.mod.mixin.api.text.MixinTextTranslatable.java

private Object[] unwrapArguments(ImmutableList<Object> args) {
    Object[] ret = new Object[args.size()];
    for (int i = 0; i < args.size(); ++i) {
        final Object arg = args.get(i);
        if (arg instanceof SpongeText) {
            ret[i] = ((SpongeText) arg).toComponent();
        } else {/*w  w  w .  j  a  v  a 2s. c om*/
            ret[i] = arg;
        }
    }
    return ret;
}

From source file:org.ow2.proactive.scheduler.common.job.factories.spi.model.validator.ListValidator.java

public ListValidator(ImmutableList<String> items) {
    if (ImmutableSet.copyOf(items).size() < items.size()) {
        throw new IllegalArgumentException("Duplicate value in list : " + items);
    }//from  w  w w . j a  va2 s .  c om
    this.listItems = items;
}

From source file:com.spectralogic.ds3cli.views.cli.TableView.java

public void initTable(final ImmutableList<String> columnHeads) {
    this.columnCount = columnHeads.size();

    // create the header
    this.header = new ASCIITableHeader[this.columnCount];
    for (int i = 0; i < this.columnCount; i++) {
        header[i] = new ASCIITableHeader(columnHeads.get(i), ASCIITable.ALIGN_LEFT);
    }//from   w  ww  .ja v  a 2s  .  com
}

From source file:ratpack.registry.internal.DefaultRegistryBuilder.java

@Override
public Registry build() {
    ImmutableList<RegistryEntry<?>> entries = builder.build();
    if (entries.size() == 1) {
        return new SingleEntryRegistry(entries.get(0));
    } else {//from w  w w.ja v  a 2 s .co  m
        return CachingRegistry.of(new MultiEntryRegistry(entries.reverse()));
    }
}

From source file:com.facebook.buck.rules.macros.EnvironmentVariableMacroExpander.java

@Override
protected String parse(BuildTarget target, CellPathResolver cellNames, ImmutableList<String> input)
        throws MacroException {
    if (input.size() != 1) {
        throw new MacroException(String.format("expected a single argument: %s", input));
    }/*from w  w w.j av  a2s.c o  m*/
    return input.get(0);
}

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

@Override
public M coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot,
        TargetConfiguration targetConfiguration, ImmutableList<String> args) throws CoerceFailedException {
    if (args.size() != 1) {
        throw new CoerceFailedException(String.format("expected exactly one argument (found %d)", args.size()));
    }/*from   w w w. j  av a  2 s.c  om*/
    return factory.apply(queryCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot,
            targetConfiguration, args.get(0)));
}

From source file:org.spongepowered.common.mixin.api.text.MixinTextTranslatable.java

private Object[] unwrapArguments(ImmutableList<Object> args) {
    Object[] result = new Object[args.size()];
    for (int i = 0; i < args.size(); i++) {
        final Object arg = args.get(i);
        if (arg instanceof IMixinText) {
            result[i] = ((IMixinText) arg).toComponent();
        } else {/*from www.j  a  v  a 2 s  .co m*/
            result[i] = arg;
        }
    }
    return result;
}

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

@Override
public M coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot,
        TargetConfiguration targetConfiguration, ImmutableList<String> args) throws CoerceFailedException {
    if (args.size() != 1) {
        throw new CoerceFailedException(String.format("expected exactly one argument (found %d)", args.size()));
    }/* ww  w  .j  av a2s  .c  o m*/
    BuildTarget target = buildTargetTypeCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot,
            targetConfiguration, args.get(0));
    return factory.apply(target);
}

From source file:com.squareup.wire.schema.internal.parser.ReservedElement.java

public final String toSchema() {
    StringBuilder builder = new StringBuilder();
    appendDocumentation(builder, documentation());
    builder.append("reserved ");
    ImmutableList<Object> value = values();
    for (int i = 0; i < value.size(); i++) {
        if (i > 0)
            builder.append(", ");

        Object reservation = value.get(i);
        if (reservation instanceof String) {
            builder.append('"').append(reservation).append('"');
        } else if (reservation instanceof Integer) {
            builder.append(reservation);
        } else if (reservation instanceof Range) {
            Range<Integer> range = (Range<Integer>) reservation;
            builder.append(range.lowerEndpoint()).append(" to ").append(range.upperEndpoint());
        } else {/* ww  w  . j  av  a 2 s  . c  o  m*/
            throw new AssertionError();
        }
    }
    return builder.append(";\n").toString();
}