List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:se.kth.climate.fast.netcdf.aligner.VariableAlignment.java
public static VariableAlignment of(List<Pair<VariableAssignment, VariableFit>> vavfs) { final ImmutableList.Builder<VariableAssignment> vas = ImmutableList.builder(); final ImmutableList.Builder<VariableFit> vfs = ImmutableList.builder(); vavfs.forEach((vavf) -> {/*from w ww.j a va 2 s .c o m*/ vas.add(vavf.getValue0()); vfs.add(vavf.getValue1()); }); return new VariableAlignment(vas.build(), vfs.build()); }
From source file:suneido.database.query.History.java
@Override List<String> columns() { if (columns == null) columns = new ImmutableList.Builder<String>().addAll(tbl.getColumns()).add("_action").add("_date") .build();// ww w . j a v a 2s . c o m return columns; }
From source file:org.jage.platform.reflect.Classes.java
/** * Returns the hierarchy of the given class as a list, starting with that class and ending in Object.class. * * @param clazz/*from w ww. j a va 2 s.c o m*/ * the target class * @return the class hierarchy of the given class * * @since 2.6 */ public static List<? extends Class<?>> classHierarchyOf(final Class<?> clazz) { Class<?> current = checkNotNull(clazz); final Builder<Class<?>> builder = ImmutableList.builder(); while (current != null) { builder.add(current); current = current.getSuperclass(); } return builder.build(); }
From source file:io.prestosql.type.FunctionType.java
private static List<TypeSignatureParameter> typeParameters(List<Type> argumentTypes, Type returnType) { requireNonNull(returnType, "returnType is null"); requireNonNull(argumentTypes, "argumentTypes is null"); ImmutableList.Builder<TypeSignatureParameter> builder = ImmutableList.builder(); argumentTypes.stream().map(Type::getTypeSignature).map(TypeSignatureParameter::of).forEach(builder::add); builder.add(TypeSignatureParameter.of(returnType.getTypeSignature())); return builder.build(); }
From source file:com.google.devtools.build.lib.skyframe.ChainUniquenessUtils.java
private static ImmutableList<Object> canonicalize(ImmutableList<? extends Object> cycle) { int minPos = 0; String minString = cycle.get(0).toString(); for (int i = 1; i < cycle.size(); i++) { // TOOD(bazel-team): Is the toString representation stable enough? String candidateString = cycle.get(i).toString(); if (candidateString.compareTo(minString) < 0) { minPos = i;/* w w w . j a v a 2 s . com*/ minString = candidateString; } } ImmutableList.Builder<Object> 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.spotify.heroic.suggest.TagValuesSuggest.java
public static Collector<TagValuesSuggest, TagValuesSuggest> reduce(final OptionalLimit limit, final OptionalLimit groupLimit) { return groups -> { final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); final Map<String, MidFlight> midflights = new HashMap<>(); boolean limited1 = false; for (final TagValuesSuggest g : groups) { errors.addAll(g.getErrors()); for (final Suggestion s : g.suggestions) { MidFlight m = midflights.get(s.key); if (m == null) { m = new MidFlight(); midflights.put(s.key, m); }//from w ww . ja va2 s. com m.values.addAll(s.values); m.limited = m.limited || s.limited; } limited1 = limited1 || g.limited; } final SortedSet<Suggestion> suggestions1 = new TreeSet<>(); for (final Map.Entry<String, MidFlight> e : midflights.entrySet()) { final String key = e.getKey(); final MidFlight m = e.getValue(); final boolean sLimited = m.limited || groupLimit.isGreater(m.values.size()); suggestions1.add(new Suggestion(key, groupLimit.limitSortedSet(m.values), sLimited)); } return new TagValuesSuggest(errors.build(), limit.limitList(ImmutableList.copyOf(suggestions1)), limited1 || limit.isGreater(suggestions1.size())); }; }
From source file:com.facebook.presto.operator.scalar.annotations.ScalarFromAnnotationsParser.java
public static List<SqlScalarFunction> parseFunctionDefinition(Class<?> clazz) { ImmutableList.Builder<SqlScalarFunction> builder = ImmutableList.builder(); for (ScalarHeaderAndMethods scalar : findScalarsInFunctionDefinitionClass(clazz)) { builder.add(parseParametricScalar(scalar, findConstructors(clazz))); }/*w w w .j a v a 2s .c o m*/ return builder.build(); }
From source file:com.publictransitanalytics.scoregenerator.output.FullPath.java
public FullPath(final MovementPath path) throws InterruptedException { final ImmutableList.Builder<String> builder = ImmutableList.builder(); for (final Movement movement : path.getMovements()) { builder.add(movement.getLongForm()); }/*from w ww .j a v a2s .c o m*/ pathLines = builder.build(); }
From source file:com.facebook.presto.execution.QueryQueueRule.java
public static QueryQueueRule createRule(@Nullable Pattern userRegex, @Nullable Pattern sourceRegex, Map<String, Pattern> sessionPropertyRegexes, List<String> queueKeys, Map<String, QueryQueueDefinition> definedQueues) { ImmutableList.Builder<QueryQueueDefinition> queues = ImmutableList.builder(); for (String key : queueKeys) { if (!definedQueues.containsKey(key)) { throw new IllegalArgumentException( format("Undefined queue %s. Defined queues are %s", key, definedQueues.keySet())); }//from w w w . jav a 2 s.c o m queues.add(definedQueues.get(key)); } return new QueryQueueRule(userRegex, sourceRegex, sessionPropertyRegexes, queues.build()); }
From source file:org.onosproject.net.resource.ContinuousResourceId.java
ContinuousResourceId(ImmutableList.Builder<Object> parentComponents, Class<?> last) { this.components = parentComponents.add(last.getCanonicalName()).build(); this.name = last.getSimpleName(); }