List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:org.ambraproject.wombat.freemarker.TemplateModelUtil.java
static ImmutableList<TemplateModel> getAsList(TemplateModel value) throws TemplateModelException { if (value == null) return ImmutableList.of(); if (value instanceof TemplateSequenceModel) { ImmutableList.Builder<TemplateModel> builder = ImmutableList.builder(); TemplateSequenceModel sequenceModel = (TemplateSequenceModel) value; int size = sequenceModel.size(); for (int i = 0; i < size; i++) { builder.add(sequenceModel.get(i)); }/*from www.j a v a2s . c om*/ return builder.build(); } else { return ImmutableList.of(value); } }
From source file:eu.eubrazilcc.lvl.core.util.LocaleUtils.java
/** * Obtains an unmodifiable list of installed locales. This method is a wrapper around * {@link Locale#getAvailableLocales()}, which caches the locales and uses generics. * @return country names.//from w w w . j ava2 s . c o m */ public static ImmutableList<Locale> availableLocaleList() { if (availableLocaleList == null) { synchronized (LocaleUtils.class) { if (availableLocaleList == null) { final ImmutableList.Builder<Locale> builder = new ImmutableList.Builder<Locale>(); final String[] locales = getISOCountries(); for (final String countryCode : locales) { builder.add(new Locale("", countryCode)); } availableLocaleList = builder.build(); } } } return availableLocaleList; }
From source file:com.spotify.heroic.metric.WriteMetric.java
public static Collector<WriteMetric, WriteMetric> reduce() { return results -> { final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); final ImmutableList.Builder<Long> times = ImmutableList.builder(); for (final WriteMetric r : results) { errors.addAll(r.getErrors()); times.addAll(r.getTimes());//from w w w .j a v a 2 s . com } return new WriteMetric(errors.build(), times.build()); }; }
From source file:com.proofpoint.reporting.Signature.java
public Signature(Method method) { this.actionName = method.getName(); Builder<String> builder = ImmutableList.builder(); for (Class<?> type : method.getParameterTypes()) { builder.add(type.getName());/*from w ww . j a v a 2 s . c o m*/ } parameterTypes = builder.build(); }
From source file:org.sonar.plugins.jacococd.JaCoCoCDPlugin.java
public List<?> getExtensions() { ImmutableList.Builder<Object> extensions = ImmutableList.builder(); extensions.addAll(JacocoCDConfiguration.getPropertyDefinitions()); extensions.add(JacocoCDConfiguration.class, JaCoCoCDAgentDownloader.class, // Ant JacocoCDAntInitializer.class, // Maven JacocoMavenCDInitializer.class, JaCoCoCDMavenPluginHandler.class, // Unit tests JaCoCoCDSensor.class, // Integration tests JaCoCoItCDSensor.class, JaCoCoCDOverallSensor.class); return extensions.build(); }
From source file:com.wrmsr.wava.util.collect.MoreLists.java
public static <T> SplitStream<T> splitStream(Stream<T> stream, Predicate<T> predicate) { ImmutableList.Builder<T> matches = ImmutableList.builder(); ImmutableList.Builder<T> nonMatches = ImmutableList.builder(); stream.forEach(e -> {/* ww w . j a va2 s . c om*/ if (predicate.test(e)) { matches.add(e); } else { nonMatches.add(e); } }); return new SplitStream<>(matches.build(), nonMatches.build()); }
From source file:org.terasology.util.io.FileScanning.java
/** * Scans a path, recursing all paths matching the scanFilter and returning all files matching the fileFilter * @param rootPath The path to scan/* w w w.jav a 2s.c o m*/ * @param scanFilter A PathMatcher indicating which subpaths to scan * @param fileFilter A PathMatcher indicating which files to return * @return A list of matching files within the path tree * @throws IOException If there is a problem walking the file tree */ public static List<Path> findFilesInPath(Path rootPath, PathMatcher scanFilter, PathMatcher fileFilter) throws IOException { final ImmutableList.Builder<Path> resultBuilder = ImmutableList.builder(); Files.walkFileTree(rootPath, new FileScanning.FilteredFileVisitor(scanFilter, fileFilter) { @Override protected void onMatch(Path file) { resultBuilder.add(file); } }); return resultBuilder.build(); }
From source file:garmintools.adapters.proto.LandingFacilityDetailProtoAdapter.java
@Override public List<LandingFacilityDetail> read(NavigationData navData) { ImmutableList.Builder<LandingFacilityDetail> listBuilder = ImmutableList.builder(); for (Proto.LandingFacility facility : navData.getLandingFacilityList()) { if (facility.hasDetail()) { listBuilder.add(/*from w ww . j a va 2 s. co m*/ LandingFacilityDetail.newBuilder().withLandingFacilityDetail(facility.getDetail()).build()); } } return listBuilder.build(); }
From source file:com.spotify.heroic.metadata.WriteMetadata.java
public static Collector<WriteMetadata, WriteMetadata> reduce() { return requests -> { final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); final ImmutableList.Builder<Long> times = ImmutableList.builder(); for (final WriteMetadata r : requests) { errors.addAll(r.getErrors()); times.addAll(r.getTimes());/*from w ww . j a v a2 s . c o m*/ } return new WriteMetadata(errors.build(), times.build()); }; }
From source file:org.gradle.model.internal.type.ClassTypeWrapper.java
@Override
public void collectClasses(ImmutableList.Builder<Class<?>> builder) {
builder.add(unwrap());
}