List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:org.syncany.plugins.transfer.TransferPluginOptions.java
private static List<TransferPluginOption> getOrderedOptions( Class<? extends TransferSettings> transferSettingsClass, int level) { List<Field> fields = getOrderedFields(transferSettingsClass); ImmutableList.Builder<TransferPluginOption> options = ImmutableList.builder(); for (Field field : fields) { TransferPluginOption option = getOptionFromField(field, transferSettingsClass, level); options.add(option); }/*from w ww .j a va2 s.c om*/ return options.build(); }
From source file:com.google.devtools.build.lib.runtime.BugReport.java
/** * Filters {@code args} by removing any item that starts with "--client_env", * then returns this as an immutable list. * * <p>The client's environment variables may contain sensitive data, so we filter it out. *///from w w w .jav a2 s . c o m private static List<String> filterClientEnv(Iterable<String> args) { if (args == null) { return null; } ImmutableList.Builder<String> filteredArgs = ImmutableList.builder(); for (String arg : args) { if (arg != null && !arg.startsWith("--client_env")) { filteredArgs.add(arg); } } return filteredArgs.build(); }
From source file:com.google.devtools.build.lib.skyframe.CycleUtils.java
static <S> Pair<ImmutableList<S>, ImmutableList<S>> splitIntoPathAndChain(Predicate<S> startOfCycle, Iterable<S> pathAndCycle) { boolean inPathToCycle = true; ImmutableList.Builder<S> pathToCycleBuilder = ImmutableList.builder(); ImmutableList.Builder<S> cycleBuilder = ImmutableList.builder(); for (S elt : pathAndCycle) { if (startOfCycle.apply(elt)) { inPathToCycle = false;//from w ww .j a v a 2s . c o m } if (inPathToCycle) { pathToCycleBuilder.add(elt); } else { cycleBuilder.add(elt); } } return Pair.of(pathToCycleBuilder.build(), cycleBuilder.build()); }
From source file:com.netflix.servo.annotations.AnnotationUtils.java
/** Return the list of fields/methods annotated with {@link Monitor}. */ public static List<AnnotatedAttribute> getMonitoredAttributes(Object obj) { List<AccessibleObject> fields = getAnnotatedFields(Monitor.class, obj, Integer.MAX_VALUE); ImmutableList.Builder<AnnotatedAttribute> attrs = ImmutableList.builder(); for (AccessibleObject field : fields) { Monitor m = field.getAnnotation(Monitor.class); attrs.add(new AnnotatedAttribute(obj, m, field)); }/* ww w .j a v a 2s. c om*/ return attrs.build(); }
From source file:com.facebook.presto.operator.scalar.annotations.ScalarFromAnnotationsParser.java
public static List<SqlScalarFunction> parseFunctionDefinitions(Class<?> clazz) { ImmutableList.Builder<SqlScalarFunction> builder = ImmutableList.builder(); for (ScalarHeaderAndMethods methods : findScalarsInFunctionSetClass(clazz)) { builder.add(parseParametricScalar(methods, findConstructors(clazz))); }/* ww w . j av a 2 s . c o m*/ return builder.build(); }
From source file:com.siemens.sw360.portal.common.datatables.DataTablesParser.java
protected static List<Map<String, String[]>> vectorize(Map<String, String[]> parametersMap) { int i = 0;/*from w ww. jav a 2 s. com*/ ImmutableList.Builder<Map<String, String[]>> builder = ImmutableList.builder(); Set<String> parametersName = parametersMap.keySet(); while (Iterables.any(parametersName, startsWith("[" + i + "]"))) { builder.add(unprefix(parametersMap, "[" + i + "]")); i++; } return builder.build(); }
From source file:com.spotify.heroic.aggregation.Aggregations.java
private static List<Aggregation> flattenChain(final Iterable<Aggregation> chain) { final ImmutableList.Builder<Aggregation> c = ImmutableList.builder(); for (final Aggregation a : chain) { if (a instanceof Chain) { c.addAll(flattenChain(Chain.class.cast(a).getChain())); } else {/*from w w w. jav a2 s . c om*/ c.add(a); } } return c.build(); }
From source file:com.noodlewiz.xjavab.ext.res.internal.ReplyUnpacker.java
public static QueryResourceBytesReply unpackQueryResourceBytes(final ByteBuffer __xjb_buf) { __xjb_buf.position(4);// w ww . j a va2 s. c om final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf); __xjb_buf.position(1); com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 1); __xjb_buf.position(8); final long numSizes = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf); com.noodlewiz.xjavab.core.internal.Unpacker.unpackPad(__xjb_buf, 20); final com.google.common.collect.ImmutableList.Builder<ResourceSizeValue> __xjb_sizesBuilder = new com.google.common.collect.ImmutableList.Builder<ResourceSizeValue>(); for (int __xjb_i = 0; (__xjb_i < numSizes); __xjb_i++) { __xjb_sizesBuilder .add(com.noodlewiz.xjavab.ext.res.internal.Unpacker.unpackResourceSizeValue(__xjb_buf)); } final List<ResourceSizeValue> sizes = __xjb_sizesBuilder.build(); return new QueryResourceBytesReply(numSizes, sizes); }
From source file:com.facebook.buck.rules.macros.StringWithMacrosUtils.java
/** @return a {@link StringWithMacros} object built with the given format strings and macros. */ public static StringWithMacros format(String format, MacroContainer... macros) { ImmutableList.Builder<Either<String, MacroContainer>> partsBuilder = ImmutableList.builder(); List<String> stringParts = Splitter.on("%s").splitToList(format); Preconditions.checkState(stringParts.size() == macros.length + 1); if (!stringParts.get(0).isEmpty()) { partsBuilder.add(Either.ofLeft(stringParts.get(0))); }//from w w w .j a va 2 s . com for (int i = 0; i < macros.length; i++) { partsBuilder.add(Either.ofRight(macros[i])); if (!stringParts.get(i + 1).isEmpty()) { partsBuilder.add(Either.ofLeft(stringParts.get(i + 1))); } } return StringWithMacros.of(partsBuilder.build()); }
From source file:org.apache.calcite.plan.RelOptMaterializations.java
/** * Returns a list of RelNode transformed from all possible combination of * materialized view uses. Big queries will likely have more than one * transformed RelNode, e.g., (t1 group by c1) join (t2 group by c2). * @param rel the original RelNode * @param materializations the materialized view list * @return the list of transformed RelNode together with their corresponding * materialized views used in the transformation. *//*from w w w . j a va 2 s .c om*/ public static List<Pair<RelNode, List<RelOptMaterialization>>> useMaterializedViews(final RelNode rel, List<RelOptMaterialization> materializations) { final List<RelOptMaterialization> applicableMaterializations = getApplicableMaterializations(rel, materializations); final List<Pair<RelNode, List<RelOptMaterialization>>> applied = new ArrayList<>(); applied.add(Pair.<RelNode, List<RelOptMaterialization>>of(rel, ImmutableList.<RelOptMaterialization>of())); for (RelOptMaterialization m : applicableMaterializations) { int count = applied.size(); for (int i = 0; i < count; i++) { Pair<RelNode, List<RelOptMaterialization>> current = applied.get(i); List<RelNode> sub = substitute(current.left, m); if (!sub.isEmpty()) { ImmutableList.Builder<RelOptMaterialization> builder = ImmutableList.builder(); builder.addAll(current.right); builder.add(m); List<RelOptMaterialization> uses = builder.build(); for (RelNode rel2 : sub) { applied.add(Pair.of(rel2, uses)); } } } } return applied.subList(1, applied.size()); }