Example usage for com.google.common.collect ImmutableList.Builder add

List of usage examples for com.google.common.collect ImmutableList.Builder add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:ec.nbdemetra.ui.interchange.impl.Configs.java

public static Configs fromExportables(List<? extends Exportable> exportables) {
    ImmutableList.Builder<Config> items = ImmutableList.builder();
    for (Exportable o : exportables) {
        items.add(o.exportConfig());
    }/*from  w w  w . j ava 2 s. c  om*/
    return new Configs(StandardSystemProperty.USER_NAME.value(), System.currentTimeMillis(), items.build());
}

From source file:com.facebook.buck.util.BuckArgsMethods.java

/**
 * Drops options from the args array./*from  ww w. j a  v  a  2 s.  co  m*/
 *
 * @param args args array.
 * @param optionsToSkip if args contains an element from this array skip the element and the
 *     element immediately after it.
 * @return filtered args array
 */
public static ImmutableList<String> filterArgs(List<String> args, ImmutableSet<String> optionsToSkip) {
    ImmutableList.Builder<String> result = ImmutableList.builder();
    for (int i = 0; i < args.size(); ++i) {
        if (optionsToSkip.contains(args.get(i))) {
            i += 1;
        } else {
            result.add(args.get(i));
        }
    }
    return result.build();
}

From source file:com.google.devtools.build.benchmark.BazelBuildCase.java

private static ImmutableList<BuildTargetConfig> getDefaultBuildTargetConfigs() {
    ImmutableList.Builder<BuildTargetConfig> builder = ImmutableList.builder();
    for (ImmutableMap.Entry<String, String> entry : BUILD_TARGET_NAME_TO_DESCRIPTION.entrySet()) {
        builder.add(BuildTargetConfig.newBuilder().setBuildTarget(entry.getKey())
                .setDescription(entry.getValue()).build());
    }//ww  w  . ja v  a  2 s .c o m
    return builder.build();
}

From source file:com.google.devtools.build.lib.rules.objc.BundleableFile.java

/**
 * Given a sequence of non-compiled resource files, returns a sequence of the same length of
 * instances of this class with the resource paths flattened (resources are put in the bundle
 * root) or, if the source file is in a directory ending in {@code .lproj}, in a directory of that
 * name directly under the bundle root.//from  www  .  ja  v a2  s  .  c  om
 *
 * <p>Non-compiled resource files are resources which are not processed before placing them in the
 * final bundle. This is different from (for example) {@code .strings} and {@code .xib} files,
 * which must be converted to binary plist form or compiled.
 *
 * @param files a sequence of artifacts corresponding to non-compiled resource files
 */
public static Iterable<BundleableFile> flattenedRawResourceFiles(Iterable<Artifact> files) {
    ImmutableList.Builder<BundleableFile> result = new ImmutableList.Builder<>();
    for (Artifact file : files) {
        result.add(new BundleableFile(file, flatBundlePath(file.getExecPath())));
    }
    return result.build();
}

From source file:com.google.devtools.build.lib.rules.objc.BundleableFile.java

/**
 * Given a sequence of non-compiled resource files, returns a sequence of the same length of
 * instances of this class with the resource paths copied as-is into the bundle root.
 *
 * <p>Non-compiled resource files are resources which are not processed before placing them in the
 * final bundle. This is different from (for example) {@code .strings} and {@code .xib} files,
 * which must be converted to binary plist form or compiled.
 *
 * @param files a sequence of artifacts corresponding to non-compiled resource files
 *///from w  w  w .  ja  v a2  s  .  c o  m
public static Iterable<BundleableFile> structuredRawResourceFiles(Iterable<Artifact> files) {
    ImmutableList.Builder<BundleableFile> result = new ImmutableList.Builder<>();
    for (Artifact file : files) {
        result.add(new BundleableFile(file, ownerBundlePath(file)));
    }
    return result.build();
}

From source file:com.google.devtools.build.lib.rules.objc.BundleableFile.java

/**
 * Returns the artifacts for the bundled files. These can be used, for instance, as the input
 * files to add to the bundlemerge action for a bundle that contains all the given files.
 *//*from ww  w  .  ja v a2 s  .c om*/
public static Iterable<Artifact> toArtifacts(Iterable<BundleableFile> files) {
    ImmutableList.Builder<Artifact> result = new ImmutableList.Builder<>();
    for (BundleableFile file : files) {
        result.add(file.bundled);
    }
    return result.build();
}

From source file:org.apache.james.transport.mailets.remoteDelivery.DelaysAndMaxRetry.java

private static List<Delay> createDelayList(String delaysAsString) {
    if (delaysAsString == null) {
        // Use default delayTime.
        return ImmutableList.of(new Delay());
    }/* ww  w  .  j  a va2s.c o  m*/
    ImmutableList<String> delayStrings = FluentIterable
            .from(Splitter.on(',').omitEmptyStrings().split(delaysAsString)).toList();
    ImmutableList.Builder<Delay> builder = ImmutableList.builder();
    try {
        for (String s : delayStrings) {
            builder.add(Delay.from(s));
        }
        return builder.build();
    } catch (Exception e) {
        LOGGER.warn("Invalid delayTime setting: {}", delaysAsString);
        return builder.build();
    }
}

From source file:com.github.imasahiro.stringformatter.processor.FormatterMethod.java

private static List<ParameterSpec> buildParamTypes(List<TypeMirror> argumentTypes) {
    ImmutableList.Builder<ParameterSpec> builder = ImmutableList.builder();
    for (int i = 0; i < argumentTypes.size(); i++) {
        builder.add(
                ParameterSpec.builder(TypeName.get(argumentTypes.get(i)), "arg" + i, Modifier.FINAL).build());
    }/*w  w  w. j  a va2 s  .com*/
    return builder.build();
}

From source file:com.noodlewiz.xjavab.ext.res.internal.Unpacker.java

public static ClientIdValue unpackClientIdValue(final ByteBuffer __xjb_buf) {
    final com.noodlewiz.xjavab.ext.res.ClientIdSpec spec = com.noodlewiz.xjavab.ext.res.internal.Unpacker
            .unpackClientIdSpec(__xjb_buf);
    final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf);
    final com.google.common.collect.ImmutableList.Builder<Long> __xjb_valueBuilder = new com.google.common.collect.ImmutableList.Builder<Long>();
    for (int __xjb_i = 0; (__xjb_i < length); __xjb_i++) {
        __xjb_valueBuilder.add(com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf));
    }// w w w.  ja  v a 2  s.  c  o m
    final List<Long> value = __xjb_valueBuilder.build();
    return new ClientIdValue(spec, length, value);
}

From source file:com.torodb.torod.db.backends.query.processors.InProcessor.java

@Nullable
private static ProcessedQueryCriteria getNumericQuery(InQueryCriteria criteria,
        Multimap<ScalarType, ScalarValue<?>> byTypeValues) {
    ImmutableList.Builder<ScalarValue<?>> newInBuilder = ImmutableList.builder();

    for (ScalarValue<?> value : byTypeValues.values()) {
        newInBuilder.add(value);
    }//from w w  w  .java2s.  c  o m

    ImmutableList<ScalarValue<?>> newIn = newInBuilder.build();

    if (newIn.isEmpty()) {
        return null;
    }

    DisjunctionBuilder structureBuilder = new DisjunctionBuilder();

    structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), ScalarType.DOUBLE));
    structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), ScalarType.INTEGER));
    structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), ScalarType.LONG));

    newInBuilder.addAll(byTypeValues.get(ScalarType.DOUBLE));
    newInBuilder.addAll(byTypeValues.get(ScalarType.INTEGER));
    newInBuilder.addAll(byTypeValues.get(ScalarType.LONG));

    return new ProcessedQueryCriteria(structureBuilder.build(),
            new InQueryCriteria(criteria.getAttributeReference(), newIn));
}