List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:com.google.cloud.genomics.dataflow.utils.CallFilters.java
public static ImmutableList<VariantCall> getSamplesWithVariantOfMinGenotype(Variant variant, int minGenotype) { ImmutableList.Builder<VariantCall> samplesWithVariant = ImmutableList.builder(); for (VariantCall call : variant.getCallsList()) { for (int genotype : call.getGenotypeList()) { if (minGenotype <= genotype) { // Use a greater than zero test since no-calls are -1 and we // don't want to count those. samplesWithVariant.add(call); break; }/*from www.jav a 2 s. com*/ } } return samplesWithVariant.build(); }
From source file:com.android.utils.ImmutableCollectors.java
public static <T> Collector<T, ImmutableList.Builder<T>, ImmutableList<T>> toImmutableList() { return Collector.of(ImmutableList::builder, ImmutableList.Builder::add, (b1, b2) -> b1.addAll(b2.build()), ImmutableList.Builder::build); }
From source file:com.codingopus.guava.custom.collectors.ImmutableListCollector.java
/** * @returns a {@link Collector} that collects data in * {@link ImmutableList}./*from w ww . j av a 2s. c o m*/ * * @param <T> The type of input elements for the new collector. * */ public static <T> Collector<T, ImmutableList.Builder<T>, ImmutableList<T>> toListCollector() { return Collector.of(ImmutableList.Builder<T>::new, ImmutableList.Builder<T>::add, (left, right) -> left.addAll(right.build()), ImmutableList.Builder<T>::build); }
From source file:com.stackframe.regex.RegularExpressions.java
/** * Compile an Iterable of regular expressions. * * @param expressions an Iterable of Strings representing regular expressions * @return an Iterable of compiled Pattern objects *//*from w w w . j a v a2 s . c o m*/ public static Iterable<Pattern> compile(Iterable<String> expressions) { ImmutableList.Builder<Pattern> b = ImmutableList.builder(); for (String expression : expressions) { b.add(Pattern.compile(expression)); } return b.build(); }
From source file:io.prestosql.operator.JoinUtils.java
public static List<Page> channelsToPages(List<List<Block>> channels) { ImmutableList.Builder<Page> pagesBuilder = ImmutableList.builder(); if (!channels.isEmpty()) { int pagesCount = channels.get(0).size(); for (int pageIndex = 0; pageIndex < pagesCount; ++pageIndex) { Block[] blocks = new Block[channels.size()]; for (int channelIndex = 0; channelIndex < channels.size(); ++channelIndex) { blocks[channelIndex] = channels.get(channelIndex).get(pageIndex); }// w w w.j av a 2 s . c o m pagesBuilder.add(new Page(blocks)); } } return pagesBuilder.build(); }
From source file:com.spectralogic.ds3client.utils.ResponseUtils.java
public static ImmutableList<Integer> toImmutableIntList(final int[] expectedStatuses) { final ImmutableList.Builder<Integer> integerBuilder = ImmutableList.builder(); if (expectedStatuses != null) { for (final int status : expectedStatuses) { integerBuilder.add(status);// w w w.j a v a 2s .c om } } return integerBuilder.build(); }
From source file:com.google.caliper.XmlUtils.java
public static ImmutableList<Node> childrenOf(Node node) { NodeList children = node.getChildNodes(); ImmutableList.Builder<Node> result = ImmutableList.builder(); for (int i = 0, size = children.getLength(); i < size; i++) { result.add(children.item(i));//from w ww .ja v a 2 s. co m } return result.build(); }
From source file:com.wrmsr.neurosis.util.ImmutableCollectors.java
public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { return Collector.<T, ImmutableList.Builder<T>, ImmutableList<T>>of(ImmutableList.Builder::new, ImmutableList.Builder::add, (left, right) -> { left.addAll(right.build()); return left; }, ImmutableList.Builder::build); }
From source file:com.github.steveash.jg2p.seq.TokenWindow.java
public static ImmutableList<TokenWindow> makeTokenWindowsForInts(int[] neighbors) { ImmutableList.Builder<TokenWindow> builder = ImmutableList.builder(); for (int i = 0; i < neighbors.length; i++) { builder.add(new TokenWindow(neighbors[i], 1)); }/*from w ww . j a v a2s . co m*/ return builder.build(); }
From source file:org.jooby.fn.Collectors.java
public static <T> Collector<T, ImmutableList.Builder<T>, List<T>> toList() { BinaryOperator<ImmutableList.Builder<T>> combiner = (l, r) -> l.addAll(r.build()); return Collector.of(ImmutableList.Builder::new, (b, e) -> b.add(e), combiner, ImmutableList.Builder::build); }