List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.facebook.buck.apple.MultiarchFileInfos.java
/** * Expand flavors representing a fat binary into its thin binary equivalents. * * Useful when dealing with functions unaware of fat binaries. * * This does not actually check that the particular flavor set is valid. *//*from w ww .j ava 2s. c om*/ public static ImmutableList<ImmutableSortedSet<Flavor>> generateThinFlavors(Set<Flavor> platformFlavors, SortedSet<Flavor> flavors) { Set<Flavor> platformFreeFlavors = Sets.difference(flavors, platformFlavors); ImmutableList.Builder<ImmutableSortedSet<Flavor>> thinTargetsBuilder = ImmutableList.builder(); for (Flavor flavor : flavors) { if (platformFlavors.contains(flavor)) { thinTargetsBuilder.add( ImmutableSortedSet.<Flavor>naturalOrder().addAll(platformFreeFlavors).add(flavor).build()); } } return thinTargetsBuilder.build(); }
From source file:com.google.devtools.build.lib.analysis.AspectResolver.java
private static AspectValue.AspectKey buildAspectKey(AspectCollection.AspectDeps aspectDeps, HashMap<AspectDescriptor, SkyKey> result, Dependency dep) { if (result.containsKey(aspectDeps.getAspect())) { return (AspectValue.AspectKey) result.get(aspectDeps.getAspect()).argument(); }//from ww w. j a va2 s. com ImmutableList.Builder<AspectValue.AspectKey> dependentAspects = ImmutableList.builder(); for (AspectCollection.AspectDeps path : aspectDeps.getDependentAspects()) { dependentAspects.add(buildAspectKey(path, result, dep)); } AspectValue.AspectKey aspectKey = AspectValue.createAspectKey(dep.getLabel(), dep.getConfiguration(), dependentAspects.build(), aspectDeps.getAspect(), dep.getAspectConfiguration(aspectDeps.getAspect())); result.put(aspectKey.getAspectDescriptor(), aspectKey.getSkyKey()); return aspectKey; }
From source file:ru.org.linux.spring.SameIPController.java
private static List<TopicItem> getComments(Connection db, String ip) throws SQLException { Statement st = db.createStatement(); ResultSet rs = st.executeQuery( "SELECT sections.name as ptitle, groups.title as gtitle, topics.title, topics.id as topicid, comments.id as msgid, comments.postdate, comments.deleted " + "FROM sections, groups, topics, comments " + "WHERE sections.id=groups.section " + "AND groups.id=topics.groupid " + "AND comments.topic=topics.id " + "AND comments.postip='" + ip + "' " + "AND comments.postdate>CURRENT_TIMESTAMP-'24 hour'::interval " + "ORDER BY postdate DESC;"); ImmutableList.Builder<TopicItem> res = ImmutableList.builder(); while (rs.next()) { res.add(new TopicItem(rs, true)); }//from ww w. ja va 2 s . c o m rs.close(); st.close(); return res.build(); }
From source file:com.spotify.heroic.aggregation.Chain.java
private static List<Aggregation> flattenChain(final List<Aggregation> chain) { final ImmutableList.Builder<Aggregation> child = ImmutableList.builder(); for (final Aggregation a : chain) { if (a instanceof Chain) { child.addAll(flattenChain(Chain.class.cast(a).getChain())); } else {/* w ww . j av a 2 s . c o m*/ child.add(a); } } return child.build(); }
From source file:com.facebook.buck.jvm.java.JavacToJarStepFactory.java
private static void addAnnotationGenFolderStep(JavacOptions buildTimeOptions, ProjectFilesystem filesystem, ImmutableList.Builder<Step> steps, BuildableContext buildableContext) { Optional<Path> annotationGenFolder = buildTimeOptions.getGeneratedSourceFolderName(); if (annotationGenFolder.isPresent()) { steps.add(new MakeCleanDirectoryStep(filesystem, annotationGenFolder.get())); buildableContext.recordArtifact(annotationGenFolder.get()); }//from ww w. j ava2 s . c om }
From source file:edu.mit.streamjit.util.CollectionUtils.java
/** * Returns the union of the given maps, using the given function to merge * values for the same key. The function is called for all keys with a list * of the values of the maps in the order the maps were given. Maps that do * not contain the key are not represented in the list. The function's * return value is used as the value in the union map. * TODO: the generics don't seem right here; I should be able to use e.g. * a Collection<Comparable> in place of List<Integer> for the middle arg. * Note that the above overload permits that and forwards to this one! * @param <K> the key type of the returned map * @param <V> the value type of the returned map * @param <X> the value type of the input map(s) * @param merger the function used to merge values for the same key * @param maps the maps/* w w w . ja v a2 s . c om*/ * @return a map containing all the keys in the given maps */ public static <K, V, X> ImmutableMap<K, V> union( Maps.EntryTransformer<? super K, ? super List<X>, ? extends V> merger, List<? extends Map<? extends K, ? extends X>> maps) { ImmutableSet.Builder<K> keys = ImmutableSet.builder(); for (Map<? extends K, ? extends X> m : maps) keys.addAll(m.keySet()); ImmutableMap.Builder<K, V> builder = ImmutableMap.builder(); for (K k : keys.build()) { ImmutableList.Builder<X> values = ImmutableList.builder(); for (Map<? extends K, ? extends X> m : maps) if (m.containsKey(k)) values.add(m.get(k)); builder.put(k, merger.transformEntry(k, values.build())); } return builder.build(); }
From source file:com.spotify.heroic.metric.FetchData.java
public static Collector<Result, Result> collectResult(final QueryTrace.Identifier what) { final QueryTrace.NamedWatch w = QueryTrace.watch(what); return results -> { final ImmutableList.Builder<QueryTrace> traces = ImmutableList.builder(); final ImmutableList.Builder<RequestError> errors = ImmutableList.builder(); for (final Result result : results) { traces.add(result.trace); errors.addAll(result.errors); }/*from w w w . j a v a 2s . c o m*/ return new Result(w.end(traces.build()), errors.build()); }; }
From source file:com.noodlewiz.xjavab.ext.render.internal.ReplyUnpacker.java
public static QueryPictIndexValuesReply unpackQueryPictIndexValues(final ByteBuffer __xjb_buf) { __xjb_buf.position(4);// w w w . j av a2s.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 numValues = 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<Indexvalue> __xjb_valuesBuilder = new com.google.common.collect.ImmutableList.Builder<Indexvalue>(); for (int __xjb_i = 0; (__xjb_i < numValues); __xjb_i++) { __xjb_valuesBuilder.add(com.noodlewiz.xjavab.ext.render.internal.Unpacker.unpackIndexvalue(__xjb_buf)); } final List<Indexvalue> values = __xjb_valuesBuilder.build(); return new QueryPictIndexValuesReply(numValues, values); }
From source file:org.killbill.billing.util.PluginProperties.java
public static List<PluginProperty> buildPluginProperties(@Nullable final Map<String, Object> data) { final ImmutableList.Builder<PluginProperty> propertiesBuilder = ImmutableList.<PluginProperty>builder(); if (data != null) { for (final String key : data.keySet()) { final PluginProperty property = new PluginProperty(key, data.get(key), false); propertiesBuilder.add(property); }//from w w w . j a v a 2 s . c o m } return propertiesBuilder.build(); }
From source file:com.noodlewiz.xjavab.ext.res.internal.ReplyUnpacker.java
public static QueryClientsReply unpackQueryClients(final ByteBuffer __xjb_buf) { __xjb_buf.position(4);/* www .j a va 2s. 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 numClients = 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<Client> __xjb_clientsBuilder = new com.google.common.collect.ImmutableList.Builder<Client>(); for (int __xjb_i = 0; (__xjb_i < numClients); __xjb_i++) { __xjb_clientsBuilder.add(com.noodlewiz.xjavab.ext.res.internal.Unpacker.unpackClient(__xjb_buf)); } final List<Client> clients = __xjb_clientsBuilder.build(); return new QueryClientsReply(numClients, clients); }