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

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

Introduction

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

Prototype

public static <E> Builder<E> builder() 

Source Link

Usage

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 w  w .j  a  va2s. c o m
        }
    }
    return keywords.build();
}

From source file:vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeWrapper.java

@SuppressWarnings("unchecked")
public RunicAltarRecipeWrapper(RecipeRuneAltar recipe) {
    ImmutableList.Builder builder = ImmutableList.builder();
    for (Object o : recipe.getInputs()) {
        if (o instanceof ItemStack) {
            builder.add(o);// w  w w .ja  v a 2s .c  om
        }
        if (o instanceof String) {
            builder.add(OreDictionary.getOres((String) o));
        }
    }
    input = builder.build();
    output = recipe.getOutput();
    manaUsage = recipe.getManaUsage();
}

From source file:com.facebook.buck.android.resources.UsedResourcesFinder.java

public static ResourceClosure computePrimaryApkClosure(ApkContentProvider apkContentProvider) {
    // The Android framework (and other apps) have easy access to the values in the manifest and
    // anything reachable from there. Also, the framework needs access to animation references to
    // drive some animations (requested by the app itself).
    ImmutableList.Builder<Integer> rootIds = ImmutableList.builder();
    ResTablePackage resPackage = apkContentProvider.getResourceTable().getPackage();
    for (ResTableTypeSpec spec : resPackage.getTypeSpecs()) {
        if (spec.getResourceTypeName(resPackage).equals("anim")) {
            int startId = (ResTablePackage.APP_PACKAGE_ID << 24) | (spec.getResourceType() << 16);
            rootIds.addAll(IntStream.range(startId, startId + spec.getEntryCount())::iterator);
        }//from  w  ww.j  ava  2s .c om
    }
    return computeClosure(apkContentProvider, ImmutableList.of("AndroidManifest.xml"), rootIds.build());
}

From source file:com.publictransitanalytics.scoregenerator.schedule.patching.Appending.java

public static List<VehicleEvent> prependToSchedule(final List<VehicleEvent> schedule,
        final List<RouteSequenceItem> extension) {
    final LocalDateTime baseTime = schedule.get(0).getScheduledTime();
    final ImmutableList.Builder<VehicleEvent> extensionBuilder = ImmutableList.builder();
    LocalDateTime lastTime = baseTime;
    for (final RouteSequenceItem item : extension) {
        final LocalDateTime newTime = lastTime.minus(item.getDelta());
        extensionBuilder.add(new VehicleEvent(item.getStop(), newTime));
        lastTime = newTime;// w w w .  j a  v  a2  s .  c o m
    }
    return ImmutableList.<VehicleEvent>builder().addAll(extensionBuilder.build().reverse()).addAll(schedule)
            .build();
}

From source file:com.publictransitanalytics.scoregenerator.output.SimplePath.java

public SimplePath(final MovementPath path) throws InterruptedException {
    final ImmutableList.Builder<String> builder = ImmutableList.builder();

    for (final Movement movement : path.getMovements()) {
        builder.add(movement.getShortForm());
    }//  w  w  w  .j ava  2  s .co  m

    pathString = String.join(" => ", builder.build());
}

From source file:org.smartdeveloperhub.vocabulary.publisher.handlers.Failure.java

public static Failure create(final String header, final String value, final Throwable cause) {
    final Builder<String> builder = ImmutableList.builder();
    Throwable failure = cause;/*from  w  w w .j  a  va 2 s . c  om*/
    while (failure != null) {
        builder.add(failure.getClass().getName() + " : " + failure.getMessage());
        failure = failure.getCause();
    }
    return new Failure(header, value, builder.build());
}

From source file:com.google.idea.blaze.base.projectview.section.GlobSectionParser.java

@Override
protected final void parseItem(ProjectViewParser parser, ParseContext parseContext,
        ImmutableList.Builder<Glob> items) {
    String text = parseContext.current().text;
    try {/*from   ww w  .  j  a v  a2s.  co  m*/
        Glob glob = new Glob(text);
        items.add(glob);
    } catch (PatternSyntaxException e) {
        parseContext.addError(e.getMessage());
    }
}

From source file:org.eclipse.xtext.formatting2.regionaccess.internal.SemanticRegionInIterableFinder.java

@Override
protected ImmutableList<ISemanticRegion> findAll(Predicate<ISemanticRegion> predicate) {
    Builder<ISemanticRegion> builder = ImmutableList.builder();
    for (ISemanticRegion region : regions)
        if (predicate.apply(region))
            builder.add(region);/*w ww .j a va2  s  .  co m*/
    return builder.build();
}

From source file:org.obiba.agate.web.rest.application.ApplicationsResource.java

@GET
public List<Agate.ApplicationDto> get() {
    ImmutableList.Builder<Agate.ApplicationDto> builder = ImmutableList.builder();

    for (Application application : applicationService.findAll()) {
        builder.add(dtos.asDto(application));
    }/*w ww.  j  a  v a  2s .c om*/

    return builder.build();
}

From source file:com.b2international.snowowl.snomed.importer.release.ReleaseFileSetSelectors.java

private static ReleaseFileSetSelector parseProperties(final Properties properties, final String prefix) {

    int idx = 0;//from w w  w.  j  a v a  2  s  .  c  om
    final ImmutableList.Builder<ReleaseFileSet> releaseFileSetBuilder = ImmutableList.builder();

    while (properties.containsKey(prefix + "." + idx + ".terminologyRoot")) {

        releaseFileSetBuilder
                .add(createSnapshotReleaseFileSet(getProperty(properties, prefix, idx, "terminologyRoot"),
                        getProperty(properties, prefix, idx, "refSetRoot"),
                        getProperty(properties, prefix, idx, "languageRefSetRoot"),
                        Boolean.valueOf(getProperty(properties, prefix, idx, "includesStatedRelationships")),
                        Boolean.valueOf(getProperty(properties, prefix, idx, "testRelease")),
                        getListProperty(properties, prefix, idx, "refSetPaths")));

        idx++;
    }

    return new ReleaseFileSetSelector(releaseFileSetBuilder.build());
}