List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.publictransitanalytics.scoregenerator.schedule.patching.Appending.java
public static List<VehicleEvent> appendToSchedule(final List<VehicleEvent> schedule, final List<RouteSequenceItem> extension) { final LocalDateTime baseTime = schedule.get(schedule.size() - 1).getScheduledTime(); final ImmutableList.Builder<VehicleEvent> builder = ImmutableList.builder(); builder.addAll(schedule);//from w w w .j av a2s. c om LocalDateTime lastTime = baseTime; for (final RouteSequenceItem item : extension) { final LocalDateTime newTime = lastTime.plus(item.getDelta()); builder.add(new VehicleEvent(item.getStop(), newTime)); lastTime = newTime; } return builder.build(); }
From source file:com.google.devtools.build.lib.analysis.actions.SymlinkTreeAction.java
private static ImmutableList<Artifact> computeInputs(Artifact inputManifest, Artifact artifactMiddleman) { ImmutableList.Builder<Artifact> result = ImmutableList.<Artifact>builder().add(inputManifest); if (artifactMiddleman != null && !artifactMiddleman.getPath().getFileSystem().supportsSymbolicLinksNatively()) { result.add(artifactMiddleman); }//from w w w .ja va 2 s . com return result.build(); }
From source file:com.facebook.presto.operator.AggregationOperator.java
private static List<Type> toTypes(Step step, List<AccumulatorFactory> accumulatorFactories) { ImmutableList.Builder<Type> types = ImmutableList.builder(); for (AccumulatorFactory accumulatorFactory : accumulatorFactories) { types.add(new Aggregator(accumulatorFactory, step).getType()); }/*w ww .jav a 2 s. co m*/ return types.build(); }
From source file:com.stackframe.sarariman.LDAPDirectory.java
private static Iterable<URL> getURLs(Attributes attributes, String attributeName) throws NamingException { Iterable<String> i = getAttributes(attributes, attributeName); ImmutableList.Builder<URL> b = ImmutableList.<URL>builder(); if (i != null) { for (String s : i) { try { b.add(new URL(s)); } catch (MalformedURLException mue) { throw new RuntimeException(mue); }/*w w w . j a v a2 s. com*/ } } return b.build(); }
From source file:com.noodlewiz.xjavab.ext.res.internal.ReplyUnpacker.java
public static QueryClientIdsReply unpackQueryClientIds(final ByteBuffer __xjb_buf) { __xjb_buf.position(4);//from w w w. j ava 2 s.c o m 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 numIds = 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<ClientIdValue> __xjb_idsBuilder = new com.google.common.collect.ImmutableList.Builder<ClientIdValue>(); for (int __xjb_i = 0; (__xjb_i < numIds); __xjb_i++) { __xjb_idsBuilder.add(com.noodlewiz.xjavab.ext.res.internal.Unpacker.unpackClientIdValue(__xjb_buf)); } final List<ClientIdValue> ids = __xjb_idsBuilder.build(); return new QueryClientIdsReply(numIds, ids); }
From source file:com.tage.calcite.adapter.druid.DruidRules.java
public static com.tage.calcite.adapter.druid.DruidQuery extendQuery( com.tage.calcite.adapter.druid.DruidQuery query, RelNode r) { final ImmutableList.Builder<RelNode> builder = ImmutableList.builder(); return DruidQuery.create(query.getCluster(), query.getTraitSet(), query.getTable(), query.druidTable, builder.addAll(query.rels).add(r).build()); }
From source file:org.prebake.service.bake.JsOperatingSystemEnv.java
static Iterable<String> stringsIn(Object[] args, int start, int end) { ImmutableList.Builder<String> b = ImmutableList.builder(); for (int i = start; i < end; ++i) { Object arg = args[i];// w ww . j a v a2s . c o m if (arg instanceof String) { b.add((String) arg); } else if (arg instanceof Iterable<?>) { for (Object o : (Iterable<?>) arg) { if (o instanceof String) { b.add((String) o); } else { throw new ClassCastException(o.getClass().getName()); } } } else { throw new ClassCastException(arg.getClass().getName()); } } return b.build(); }
From source file:com.sun.tools.hat.internal.lang.openjdk6.JavaLinkedList.java
public static JavaLinkedList make(JavaObject list) { JavaObject header = Models.getFieldObject(list, "header"); if (header == null) return null; ImmutableList.Builder<JavaThing> builder = ImmutableList.builder(); for (JavaObject entry = Models.getFieldObject(header, "next"); entry != header; entry = Models .getFieldObject(entry, "next")) { if (entry == null) return null; builder.add(entry.getField("element")); }/*from w w w .ja v a2 s .c o m*/ return new JavaLinkedList(builder.build()); }
From source file:com.pingcap.tikv.predicates.RangeBuilder.java
private static List<Object> exprToPoints(TiExpr expr, DataType type) { try {//from w w w . j a v a 2 s .co m if (expr instanceof Or) { Or orExpr = (Or) expr; return ImmutableList.builder().addAll(exprToPoints(orExpr.getArg(0), type)) .addAll(exprToPoints(orExpr.getArg(1), type)).build(); } checkArgument(expr instanceof Equal || expr instanceof In, "Only In and Equal can convert to points"); TiFunctionExpression func = (TiFunctionExpression) expr; NormalizedCondition cond = AccessConditionNormalizer.normalize(func); ImmutableList.Builder<Object> result = ImmutableList.builder(); cond.constantVals.forEach(constVal -> result.add(checkAndExtractConst(constVal, type))); return result.build(); } catch (Exception e) { throw new TiClientInternalException("Failed to convert expr to points: " + expr, e); } }
From source file:com.spotify.heroic.grammar.Expression.java
static List<Expression> evalList(List<Expression> list, Scope scope) { final ImmutableList.Builder<Expression> evaled = ImmutableList.builder(); for (final Expression e : list) { evaled.add(e.eval(scope)); }//www.ja v a2 s . c om return evaled.build(); }