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:org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.java

public static TreeComplexUsesAugment complexUsesAugment(final ListViaUsesKey... keys) {
    final ImmutableList.Builder<ListViaUses> listViaUses = ImmutableList.<ListViaUses>builder();
    for (final ListViaUsesKey key : keys) {
        listViaUses.add(new ListViaUsesBuilder().setKey(key).build());
    }// w w  w  .j  a v  a 2s.c  om
    return new TreeComplexUsesAugmentBuilder().setListViaUses(listViaUses.build()).build();
}

From source file:com.google.devtools.build.lib.skyframe.AbstractFileSymlinkExceptionUniquenessValue.java

private static ImmutableList<RootedPath> canonicalize(ImmutableList<RootedPath> cycle) {
    int minPos = 0;
    String minString = cycle.get(0).toString();
    for (int i = 1; i < cycle.size(); i++) {
        String candidateString = cycle.get(i).toString();
        if (candidateString.compareTo(minString) < 0) {
            minPos = i;/* w ww  .j a v a  2s  .  c o m*/
            minString = candidateString;
        }
    }
    ImmutableList.Builder<RootedPath> builder = ImmutableList.builder();
    for (int i = 0; i < cycle.size(); i++) {
        int pos = (minPos + i) % cycle.size();
        builder.add(cycle.get(pos));
    }
    return builder.build();
}

From source file:com.facebook.buck.apple.GroupedSources.java

private static void addSourcePathsToBuilder(ImmutableList.Builder<SourcePath> sourcePathsBuilder,
        GroupedSource groupedSource) {// ww  w  . j a  v a  2  s.  com
    switch (groupedSource.getType()) {
    case SOURCE_PATH:
        sourcePathsBuilder.add(groupedSource.getSourcePath());
        break;
    case SOURCE_GROUP:
        for (GroupedSource sourceGroupEntry : groupedSource.getSourceGroup()) {
            addSourcePathsToBuilder(sourcePathsBuilder, sourceGroupEntry);
        }
        break;
    default:
        throw new IllegalStateException("Unhandled type: " + groupedSource.getType());
    }
}

From source file:ninja.leaping.permissionsex.util.glob.Globs.java

private static List<GlobNode> parseValues(Object[] objs) {
    ImmutableList.Builder<GlobNode> vals = ImmutableList.builder();
    for (Object o : objs) {
        if (o instanceof GlobNode) {
            vals.add((GlobNode) o);
        } else {//  w  ww. j a  va2 s  .  c om
            vals.add(literal(String.valueOf(o)));
        }
    }
    return vals.build();
}

From source file:com.android.build.gradle.ndk.internal.StlConfiguration.java

public static Collection<String> getStlSources(NdkHandler ndkHandler, String stl) {
    final File stlBase = getStlBaseDirectory(ndkHandler);
    String stlName = stl.equals("system") ? "system" : stl.substring(0, stl.indexOf('_'));

    ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (String sourceDir : STL_SOURCES.get(stlName)) {
        builder.add(stlBase.toString() + "/" + sourceDir);
    }// www.  j  a  v a2  s.  c o  m
    return builder.build();
}

From source file:org.apache.beam.sdk.values.reflect.DefaultRowTypeFactory.java

private static List<String> getFieldNames(Iterable<FieldValueGetter> fieldValueGetters) {
    ImmutableList.Builder<String> names = ImmutableList.builder();

    for (FieldValueGetter fieldValueGetter : fieldValueGetters) {
        names.add(fieldValueGetter.name());
    }// w  w w.  j  a  va  2s.  c om

    return names.build();
}

From source file:org.ratpackframework.guice.internal.GuiceUtil.java

public static <T> ImmutableList<T> ofType(Injector injector, TypeLiteral<T> type) {
    final ImmutableList.Builder<T> listBuilder = ImmutableList.builder();
    eachOfType(injector, type, new Action<T>() {
        public void execute(T thing) {
            listBuilder.add(thing);
        }/*from   www .  j  a va2 s  .  co m*/
    });
    return listBuilder.build();
}

From source file:com.google.devtools.build.xcode.xcodegen.testing.PbxTypes.java

/**
 * Transforms the given list of PBX references to file references.
 *//*from   w ww. ja v  a 2s . c  o m*/
public static ImmutableList<FileReference> fileReferences(Iterable<? extends PBXReference> references) {
    ImmutableList.Builder<FileReference> fileReferences = ImmutableList.builder();
    for (PBXReference reference : references) {
        fileReferences.add(fileReference(reference));
    }
    return fileReferences.build();
}

From source file:org.sonar.flex.FlexKeyword.java

public static List<FlexKeyword> keywords() {
    ImmutableList.Builder<FlexKeyword> keywords = ImmutableList.builder();
    for (FlexKeyword keyword : values()) {
        if (!keyword.syntactic) {
            keywords.add(keyword);
        }//from w  ww . j a v  a2  s .c o  m
    }
    return keywords.build();
}

From source file:com.mingo.parser.xml.dom.DocumentBuilderFactoryCreator.java

/**
 * Create list of {@link Source} objects.
 *
 * @param xsdSchemaPaths paths to some schemas
 * @return list of {@link Source}//  w w w  . j  av a 2  s  .  c  o  m
 */
private static List<Source> createSchemaSources(Set<String> xsdSchemaPaths) {
    if (CollectionUtils.isEmpty(xsdSchemaPaths)) {
        return ImmutableList.of();
    }

    ImmutableList.Builder sourceBuilder = ImmutableList.<Source>builder();
    for (String xsdSchemaPath : xsdSchemaPaths) {
        sourceBuilder.add(createSchemaSource(xsdSchemaPath));
    }
    return sourceBuilder.build();
}