List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:com.facebook.buck.apple.GroupedSources.java
/** * Returns an infix-order traversal of the {@link SourcePath}s of * each {@link GroupedSource} and its children in the input list. *//*from w w w . j av a2 s . c o m*/ public static ImmutableCollection<SourcePath> sourcePaths(Iterable<GroupedSource> groupedSources) { ImmutableList.Builder<SourcePath> sourcePathsBuilder = ImmutableList.builder(); for (GroupedSource groupedSource : groupedSources) { addSourcePathsToBuilder(sourcePathsBuilder, groupedSource); } return sourcePathsBuilder.build(); }
From source file:com.facebook.buck.cxx.elf.ElfSymbolTable.java
public static ElfSymbolTable parse(ElfHeader.EIClass eiClass, ByteBuffer buffer) { ImmutableList.Builder<Entry> entries = ImmutableList.builder(); while (buffer.hasRemaining()) { entries.add(Entry.parse(eiClass, buffer)); }//from w w w . j av a2 s. c om return new ElfSymbolTable(entries.build()); }
From source file:org.kairosdb.testing.BeanValidationHelper.java
public static List<String> messagesFor(Collection<? extends ConstraintViolation<?>> violations) { ImmutableList.Builder<String> messages = new ImmutableList.Builder<String>(); for (ConstraintViolation<?> violation : violations) { messages.add(violation.getPropertyPath().toString() + " " + violation.getMessage()); }/*w ww .j a v a 2 s. c o m*/ return messages.build(); }
From source file:io.dfox.junit.http.util.Collectors.java
/** * Create a new Collector for a Guava ImmutableList. * // ww w .j a v a 2s . c om * @param <T> The type of list * @return The Collector for a Guava ImmutableList */ public static <T> Collector<T, ImmutableList.Builder<T>, ImmutableList<T>> toImmutableList() { return Collector.of(ImmutableList.Builder::new, (builder, e) -> builder.add(e), (b1, b2) -> b1.addAll(b2.build()), (builder) -> builder.build()); }
From source file:io.crate.sql.tree.QueryUtil.java
public static Select selectList(Expression... expressions) { ImmutableList.Builder<SelectItem> items = ImmutableList.builder(); for (Expression expression : expressions) { items.add(new SingleColumn(expression)); }/*from w w w . j av a2 s .c om*/ return new Select(false, items.build()); }
From source file:org.eclipse.buildship.ui.util.gradle.GradleUtils.java
/** * Filters away those tests that are a child of a test from the given list of tests. * * @param testDescriptors the tests to filter * @return the filtered tests where no test has as a parent a test that is also part of the result */// w w w .ja v a2 s . co m public static List<TestOperationDescriptor> filterChildren(List<TestOperationDescriptor> testDescriptors) { ImmutableList.Builder<TestOperationDescriptor> withoutChildren = ImmutableList.builder(); for (TestOperationDescriptor testDescriptor : testDescriptors) { if (!isParentSelected(testDescriptor, testDescriptors)) { withoutChildren.add(testDescriptor); } } return withoutChildren.build(); }
From source file:com.facebook.presto.operator.PartitionGenerator.java
static PartitionGenerator createHashPartitionGenerator(Optional<Integer> hashChannel, List<Integer> partitioningChannels, List<Type> types) { if (hashChannel.isPresent()) { return new PrecomputedHashGenerator(hashChannel.get()); }// www . ja v a 2 s. c om ImmutableList.Builder<Type> hashTypes = ImmutableList.builder(); int[] hashChannels = new int[partitioningChannels.size()]; for (int i = 0; i < partitioningChannels.size(); i++) { int channel = partitioningChannels.get(i); hashTypes.add(types.get(channel)); hashChannels[i] = channel; } return new InterpretedHashGenerator(hashTypes.build(), hashChannels); }
From source file:io.prestosql.plugin.mongodb.MongoIndex.java
public static List<MongoIndex> parse(ListIndexesIterable<Document> indexes) { ImmutableList.Builder<MongoIndex> builder = ImmutableList.builder(); for (Document index : indexes) { // TODO: v, ns, sparse fields Document key = (Document) index.get("key"); String name = index.getString("name"); boolean unique = index.getBoolean("unique", false); if (key.containsKey("_fts")) { // Full Text Search continue; }//from ww w.ja v a 2s . co m builder.add(new MongoIndex(name, parseKey(key), unique)); } return builder.build(); }
From source file:org.locationtech.geogig.api.RevFeatureBuilder.java
/** * Constructs a new {@link RevFeature} from the provided {@link Feature}. * /*from w w w. j av a2 s . c o m*/ * @param feature the feature to build from * @return the newly constructed RevFeature */ public static RevFeature build(Feature feature) { if (feature == null) { throw new IllegalStateException("No feature set"); } Collection<Property> props = feature.getProperties(); ImmutableList.Builder<Optional<Object>> valuesBuilder = new ImmutableList.Builder<Optional<Object>>(); for (Property prop : props) { valuesBuilder.add(Optional.fromNullable(prop.getValue())); } return RevFeatureImpl.build(valuesBuilder.build()); }
From source file:com.publictransitanalytics.scoregenerator.schedule.IntervalOfDay.java
public static List<IntervalOfDay> getIntervals(final LocalDateTime earliestTime, final LocalDateTime latestTime) { final ImmutableList.Builder<IntervalOfDay> intervals = ImmutableList.builder(); if (earliestTime.toLocalDate().equals(latestTime.toLocalDate())) { intervals.add(new IntervalOfDay(earliestTime.toLocalDate(), earliestTime.toLocalTime(), latestTime.toLocalTime())); } else {/*from ww w . j av a 2 s. c om*/ intervals.add(new IntervalOfDay(earliestTime.toLocalDate(), earliestTime.toLocalTime(), LocalTime.MAX)); LocalDate date = earliestTime.toLocalDate().plusDays(1); while (date.isBefore(latestTime.toLocalDate())) { intervals.add(new IntervalOfDay(date, LocalTime.MIN, LocalTime.MAX)); date = date.plusDays(1); } intervals.add(new IntervalOfDay(latestTime.toLocalDate(), LocalTime.MIN, latestTime.toLocalTime())); } return intervals.build(); }