List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.noodlewiz.xjavab.ext.shape.internal.ReplyUnpacker.java
public static GetRectanglesReply unpackGetRectangles(final ByteBuffer __xjb_buf) { __xjb_buf.position(4);// w w w. ja v a2s . c o m final long length = com.noodlewiz.xjavab.core.internal.Unpacker.unpackUInt(__xjb_buf); __xjb_buf.position(1); final byte ordering = com.noodlewiz.xjavab.core.internal.Unpacker.unpackByte(__xjb_buf); __xjb_buf.position(8); final long rectanglesLen = 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<Rectangle> __xjb_rectanglesBuilder = new com.google.common.collect.ImmutableList.Builder<Rectangle>(); for (int __xjb_i = 0; (__xjb_i < rectanglesLen); __xjb_i++) { __xjb_rectanglesBuilder .add(com.noodlewiz.xjavab.core.xproto.internal.Unpacker.unpackRectangle(__xjb_buf)); } final List<Rectangle> rectangles = __xjb_rectanglesBuilder.build(); return new GetRectanglesReply(ordering, rectanglesLen, rectangles); }
From source file:io.crate.metadata.Signature.java
/** * Build signatures of paired combinations of all given types including same types e.g. (string, string) *///from www .j av a2 s . co m public static List<Signature> pairedCombinationsOf(Collection<DataType> dataTypes) { ImmutableList.Builder<Signature> builder = ImmutableList.builder(); for (DataType leftType : dataTypes) { for (DataType rightType : dataTypes) { builder.add(new Signature(leftType, rightType)); } } return builder.build(); }
From source file:com.google.devtools.build.android.SerializedAndroidData.java
protected static ImmutableList<Path> splitPaths(String pathsString, FileSystem fileSystem) { if (pathsString.trim().isEmpty()) { return ImmutableList.of(); }//from w w w .ja v a 2 s . c om ImmutableList.Builder<Path> paths = new ImmutableList.Builder<>(); for (String pathString : pathsString.split("#")) { Preconditions.checkArgument(!pathString.trim().isEmpty()); paths.add(exists(fileSystem.getPath(pathString))); } return paths.build(); }
From source file:com.github.rinde.logistics.pdptw.solver.CheapestInsertionHeuristic.java
static <T> ImmutableList<ImmutableList<T>> modifySchedule(ImmutableList<ImmutableList<T>> originalSchedule, ImmutableList<T> vehicleSchedule, int vehicleIndex) { checkArgument(vehicleIndex >= 0 && vehicleIndex < originalSchedule.size(), "Vehicle index must be >= 0 && < %s, it is %s.", originalSchedule.size(), vehicleIndex); final ImmutableList.Builder<ImmutableList<T>> builder = ImmutableList.builder(); builder.addAll(originalSchedule.subList(0, vehicleIndex)); builder.add(vehicleSchedule); builder.addAll(originalSchedule.subList(vehicleIndex + 1, originalSchedule.size())); return builder.build(); }
From source file:io.prestosql.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, FunctionsParserHelper.findConstructor(clazz))); }/* w w w . ja va 2 s. c o m*/ return builder.build(); }
From source file:com.publictransitanalytics.scoregenerator.schedule.patching.Appending.java
public static List<VehicleEvent> prependToSchedule(final List<VehicleEvent> schedule, final List<RouteSequenceItem> extension) { final LocalDateTime baseTime = schedule.get(0).getScheduledTime(); final ImmutableList.Builder<VehicleEvent> extensionBuilder = ImmutableList.builder(); LocalDateTime lastTime = baseTime; for (final RouteSequenceItem item : extension) { final LocalDateTime newTime = lastTime.minus(item.getDelta()); extensionBuilder.add(new VehicleEvent(item.getStop(), newTime)); lastTime = newTime;//w w w .j a v a 2 s. c o m } return ImmutableList.<VehicleEvent>builder().addAll(extensionBuilder.build().reverse()).addAll(schedule) .build(); }
From source file:org.sonar.plugins.dotnet.tests.WildcardPatternFileProvider.java
private static List<String> elementsTillFirstWildcard(List<String> elements) { ImmutableList.Builder<String> builder = ImmutableList.builder(); for (String element : elements) { if (containsWildcard(element)) { break; }/*from w w w.j av a2 s .co m*/ builder.add(element); } return builder.build(); }
From source file:io.prestosql.orc.metadata.OrcType.java
public static List<OrcType> createOrcRowType(int nextFieldTypeIndex, List<String> fieldNames, List<Type> fieldTypes) { nextFieldTypeIndex++;//from w ww . j a v a 2 s. c o m List<Integer> fieldTypeIndexes = new ArrayList<>(); List<List<OrcType>> fieldTypesList = new ArrayList<>(); for (Type fieldType : fieldTypes) { fieldTypeIndexes.add(nextFieldTypeIndex); List<OrcType> fieldOrcTypes = toOrcType(nextFieldTypeIndex, fieldType); fieldTypesList.add(fieldOrcTypes); nextFieldTypeIndex += fieldOrcTypes.size(); } ImmutableList.Builder<OrcType> orcTypes = ImmutableList.builder(); orcTypes.add(new OrcType(OrcTypeKind.STRUCT, fieldTypeIndexes, fieldNames)); fieldTypesList.forEach(orcTypes::addAll); return orcTypes.build(); }
From source file:org.waveprotocol.box.server.waveserver.WaveletNotificationDispatcher.java
/** Picks out the byte strings of the applied deltas from a list of delta records. */ private static ImmutableList<ByteString> serializedAppliedDeltasOf(Iterable<WaveletDeltaRecord> deltaRecords) { ImmutableList.Builder<ByteString> serializedAppliedDeltas = ImmutableList.builder(); for (WaveletDeltaRecord deltaRecord : deltaRecords) { serializedAppliedDeltas.add(deltaRecord.getAppliedDelta().getByteString()); }/*from w w w.j a va2 s . co m*/ return serializedAppliedDeltas.build(); }
From source file:com.spotify.heroic.metric.FetchData.java
@Deprecated public static Collector<FetchData, FetchData> collect(final QueryTrace.Identifier what) { final Collector<Result, Result> resultCollector = collectResult(what); return fetchDataCollection -> { final ImmutableList.Builder<Long> times = ImmutableList.builder(); final Map<MetricType, ImmutableList.Builder<Metric>> fetchGroups = new HashMap<>(); final ImmutableList.Builder<Result> results = ImmutableList.builder(); for (final FetchData fetch : fetchDataCollection) { times.addAll(fetch.times);//from w ww .ja va 2 s . c o m results.add(fetch.result); for (final MetricCollection g : fetch.groups) { ImmutableList.Builder<Metric> data = fetchGroups.get(g.getType()); if (data == null) { data = new ImmutableList.Builder<>(); fetchGroups.put(g.getType(), data); } data.addAll(g.data); } } final List<MetricCollection> groups = fetchGroups.entrySet().stream() .map((e) -> MetricCollection.build(e.getKey(), Ordering.from(Metric.comparator()).immutableSortedCopy(e.getValue().build()))) .collect(Collectors.toList()); return new FetchData(resultCollector.collect(results.build()), times.build(), groups); }; }