List of usage examples for com.google.common.collect ImmutableList.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:org.javabits.yar.guice.osgi.YarOSGis.java
private static Iterable<Module> getModules(BundleContext bundleContext, Iterable<Module> modules) { ImmutableList.Builder<Module> modulesBuilder = ImmutableList.builder(); modulesBuilder.add(newYarOSGiModule(bundleContext)); modulesBuilder.addAll(modules); return modulesBuilder.build(); }
From source file:org.prebake.js.CommonEnvironment.java
private static ImmutableList<Glob> parseGlobs(Object jsObj) { MessageQueue mq = new MessageQueue(); ImmutableList.Builder<Glob> out = ImmutableList.builder(); if (jsObj instanceof Iterable<?>) { for (Object item : ((Iterable<?>) jsObj)) { out.addAll(Glob.CONV.convert(item, mq)); }/*from w w w . j a v a2 s. c om*/ } else { out.addAll(Glob.CONV.convert(jsObj, mq)); } if (mq.hasErrors()) { throw new IllegalArgumentException(Joiner.on('\n').join(mq.getMessages())); } return out.build(); }
From source file:com.publictransitanalytics.scoregenerator.schedule.patching.RouteReroute.java
private static LocalDateTime makeForwardPreDivergingPortion(final List<VehicleEvent> schedule, final int divergingIndex, final ImmutableList.Builder<VehicleEvent> scheduleBuilder) { final List<VehicleEvent> beginning = schedule.subList(0, divergingIndex + 1); scheduleBuilder.addAll(beginning); final VehicleEvent lastLocation = beginning.get(beginning.size() - 1); final LocalDateTime lastTime = lastLocation.getScheduledTime(); return lastTime; }
From source file:com.galois.qrstream.qrpipe.PartialMessage.java
/** * Extract raw bytes from decoded QR code. If none can be extracted, * then this method returns {@code null}. *///w ww. ja v a 2 s . c o m private static byte[] getRawData(final Result decodedQR) { // Whenever the ZXing result metadata is missing or does not // have the BYTE_SEGMENTS object return null to indicate error. // Might happen if we're trying to read a non-streaming type of QR code. Map<ResultMetadataType, ?> meta = decodedQR.getResultMetadata(); if (meta == null || !meta.containsKey(ResultMetadataType.BYTE_SEGMENTS)) { return null; } ImmutableList.Builder<Byte> msgBuilder = new ImmutableList.Builder<Byte>(); @SuppressWarnings("unchecked") List<byte[]> dataSegments = (List<byte[]>) meta.get(ResultMetadataType.BYTE_SEGMENTS); for (byte[] bs : dataSegments) { msgBuilder.addAll(Bytes.asList(bs)); } return Bytes.toArray(msgBuilder.build()); }
From source file:dagger2.internal.codegen.writer.Snippet.java
public static Snippet makeParametersSnippet(Iterable<Snippet> parameterSnippets) { Iterator<Snippet> iterator = parameterSnippets.iterator(); StringBuilder stringBuilder = new StringBuilder(); ImmutableSet.Builder<TypeName> typesBuilder = ImmutableSet.builder(); ImmutableList.Builder<Object> argsBuilder = ImmutableList.builder(); if (iterator.hasNext()) { Snippet firstSnippet = iterator.next(); stringBuilder.append(firstSnippet.format()); typesBuilder.addAll(firstSnippet.types()); argsBuilder.addAll(firstSnippet.args()); }//from w ww . j a v a 2 s. com while (iterator.hasNext()) { Snippet nextSnippet = iterator.next(); stringBuilder.append(", ").append(nextSnippet.format()); typesBuilder.addAll(nextSnippet.types()); argsBuilder.addAll(nextSnippet.args()); } return new Snippet(stringBuilder.toString(), typesBuilder.build(), argsBuilder.build()); }
From source file:com.facebook.presto.server.PluginDiscovery.java
private static List<String> classInterfaces(String name, ClassLoader classLoader) { ImmutableList.Builder<String> list = ImmutableList.builder(); ClassReader reader = readClass(name, classLoader); for (String binaryName : reader.getInterfaces()) { list.add(javaName(binaryName));//from w ww. j a v a 2 s . co m } if (reader.getSuperName() != null) { list.addAll(classInterfaces(javaName(reader.getSuperName()), classLoader)); } return list.build(); }
From source file:com.indeema.email.provider.AccountReconciler.java
/** * Get all AccountManager accounts for all email types. * @param context Our {@link android.content.Context}. * @return A list of all {@link android.accounts.Account}s created by our app. *//*from w w w. j a v a 2s .c om*/ private static List<android.accounts.Account> getAllAmAccounts(final Context context) { final AccountManager am = AccountManager.get(context); final ImmutableList.Builder<android.accounts.Account> builder = ImmutableList.builder(); // TODO: Consider getting the types programmatically, in case we add more types. builder.addAll( Arrays.asList(am.getAccountsByType(context.getString(R.string.account_manager_type_legacy_imap)))); builder.addAll(Arrays.asList(am.getAccountsByType(context.getString(R.string.account_manager_type_pop3)))); builder.addAll( Arrays.asList(am.getAccountsByType(context.getString(R.string.account_manager_type_exchange)))); return builder.build(); }
From source file:co.cask.cdap.internal.app.runtime.batch.MapReduceClassLoader.java
/** * Creates the delegating list of ClassLoader. *//*from w w w. java 2 s. com*/ private static List<ClassLoader> createDelegates(Parameters parameters) { ImmutableList.Builder<ClassLoader> builder = ImmutableList.builder(); builder.add(parameters.getProgramClassLoader()); builder.addAll(parameters.getFilteredPluginClassLoaders()); builder.add(MapReduceClassLoader.class.getClassLoader()); return builder.build(); }
From source file:com.facebook.presto.operator.HashAggregationOperator.java
private static List<Type> toTypes(List<? extends Type> groupByType, Step step, List<AccumulatorFactory> factories, Optional<Integer> hashChannel) { ImmutableList.Builder<Type> types = ImmutableList.builder(); types.addAll(groupByType); if (hashChannel.isPresent()) { types.add(BIGINT);/*from w w w . j a v a 2 s. c o m*/ } for (AccumulatorFactory factory : factories) { types.add(new Aggregator(factory, step).getType()); } return types.build(); }
From source file:com.facebook.presto.raptor.storage.organization.ShardOrganizerUtil.java
public static Collection<Collection<ShardIndexInfo>> getShardsByDaysBuckets(Table tableInfo, Collection<ShardIndexInfo> shards) { // Neither bucketed nor temporal, no partitioning required if (!tableInfo.getBucketCount().isPresent() && !tableInfo.getTemporalColumnId().isPresent()) { return ImmutableList.of(shards); }//from w w w .j a v a2 s. c o m // if only bucketed, partition by bucket number if (tableInfo.getBucketCount().isPresent() && !tableInfo.getTemporalColumnId().isPresent()) { return Multimaps.index(shards, shard -> shard.getBucketNumber().getAsInt()).asMap().values(); } // if temporal, partition into days first ImmutableMultimap.Builder<Long, ShardIndexInfo> shardsByDaysBuilder = ImmutableMultimap.builder(); shards.stream().filter(shard -> shard.getTemporalRange().isPresent()).forEach(shard -> { long day = determineDay(shard.getTemporalRange().get()); shardsByDaysBuilder.put(day, shard); }); Collection<Collection<ShardIndexInfo>> byDays = shardsByDaysBuilder.build().asMap().values(); // if table is bucketed further partition by bucket number if (!tableInfo.getBucketCount().isPresent()) { return byDays; } ImmutableList.Builder<Collection<ShardIndexInfo>> sets = ImmutableList.builder(); for (Collection<ShardIndexInfo> s : byDays) { sets.addAll(Multimaps.index(s, ShardIndexInfo::getBucketNumber).asMap().values()); } return sets.build(); }