List of usage examples for com.google.common.collect ImmutableSet.Builder add
boolean add(E e);
From source file:com.facebook.buck.features.go.GoDescriptors.java
private static ImmutableSet<GoLinkable> requireGoLinkables(BuildTarget sourceTarget, ActionGraphBuilder graphBuilder, GoPlatform platform, Iterable<BuildTarget> targets) { ImmutableSet.Builder<GoLinkable> linkables = ImmutableSet.builder(); new AbstractBreadthFirstTraversal<BuildTarget>(targets) { @Override/*from w w w . j a v a2s . co m*/ public Iterable<BuildTarget> visit(BuildTarget target) { GoLinkable linkable = requireGoLinkable(sourceTarget, graphBuilder, platform, target); linkables.add(linkable); return linkable.getExportedDeps(); } }.start(); return linkables.build(); }
From source file:org.glowroot.agent.embedded.util.Schemas.java
@VisibleForTesting static ImmutableSet<Index> getIndexes(String tableName, Connection connection) throws SQLException { ListMultimap</*@Untainted*/ String, /*@Untainted*/ String> indexColumns = ArrayListMultimap.create(); ResultSet resultSet = getMetaDataIndexInfo(connection, tableName); ResultSetCloser closer = new ResultSetCloser(resultSet); try {/*w w w . j a v a2 s . c o m*/ while (resultSet.next()) { String indexName = checkNotNull(resultSet.getString("INDEX_NAME")); String columnName = checkNotNull(resultSet.getString("COLUMN_NAME")); // hack-ish to skip over primary key constraints which seem to be always // prefixed in H2 by PRIMARY_KEY_ if (!indexName.startsWith("PRIMARY_KEY_")) { indexColumns.put(castUntainted(indexName), castUntainted(columnName)); } } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } ImmutableSet.Builder<Index> indexes = ImmutableSet.builder(); for (Map.Entry</*@Untainted*/ String, Collection</*@Untainted*/ String>> entry : indexColumns.asMap() .entrySet()) { String name = entry.getKey().toLowerCase(Locale.ENGLISH); List<String> columns = Lists.newArrayList(); for (String column : entry.getValue()) { columns.add(column.toLowerCase(Locale.ENGLISH)); } indexes.add(ImmutableIndex.of(name, columns)); } return indexes.build(); }
From source file:com.facebook.presto.operator.scalar.annotations.ScalarFromAnnotationsParser.java
@SafeVarargs private static Set<Method> findPublicMethodsWithAnnotation(Class<?> clazz, Class<? extends Annotation>... annotationClasses) { ImmutableSet.Builder<Method> methods = ImmutableSet.builder(); for (Method method : clazz.getDeclaredMethods()) { for (Annotation annotation : method.getAnnotations()) { for (Class<?> annotationClass : annotationClasses) { if (annotationClass.isInstance(annotation)) { checkArgument(Modifier.isPublic(method.getModifiers()), "Method [%s] annotated with @%s must be public", method, annotationClass.getSimpleName()); methods.add(method); }//from w w w .j av a 2 s . c o m } } } return methods.build(); }
From source file:org.daisy.maven.xspec.XSpecRunner.java
public static Set<File> listXSpecFilesRecursively(File directory) { ImmutableSet.Builder<File> builder = new ImmutableSet.Builder<File>(); if (directory.isDirectory()) for (File file : directory.listFiles()) { if (file.isDirectory()) builder.addAll(listXSpecFilesRecursively(file)); else if (file.getName().endsWith(".xspec")) builder.add(file); }// w w w . j a v a 2 s . co m return builder.build(); }
From source file:com.publictransitanalytics.scoregenerator.Main.java
private static Set<Center> getSampleCenters(final Set<Sector> samples, final Grid grid) { final ImmutableSet.Builder<Center> builder = ImmutableSet.builder(); for (final Sector sector : samples) { builder.add(new Center(sector, grid.getGridPoints(sector))); }/*from ww w.j a va2 s . co m*/ return builder.build(); }
From source file:org.glowroot.agent.fat.storage.util.Schemas.java
@VisibleForTesting static ImmutableSet<Index> getIndexes(String tableName, Connection connection) throws SQLException { ListMultimap</*@Untainted*/ String, /*@Untainted*/ String> indexColumns = ArrayListMultimap.create(); ResultSet resultSet = getMetaDataIndexInfo(connection, tableName); ResultSetCloser closer = new ResultSetCloser(resultSet); try {/* w w w .ja v a 2 s . co m*/ while (resultSet.next()) { String indexName = checkNotNull(resultSet.getString("INDEX_NAME")); String columnName = checkNotNull(resultSet.getString("COLUMN_NAME")); // hack-ish to skip over primary key constraints which seem to be always // prefixed in H2 by PRIMARY_KEY_ if (!indexName.startsWith("PRIMARY_KEY_")) { indexColumns.put(castUntainted(indexName), castUntainted(columnName)); } } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } ImmutableSet.Builder<Index> indexes = ImmutableSet.builder(); for (Entry</*@Untainted*/ String, Collection</*@Untainted*/ String>> entry : indexColumns.asMap() .entrySet()) { String name = entry.getKey().toLowerCase(Locale.ENGLISH); List<String> columns = Lists.newArrayList(); for (String column : entry.getValue()) { columns.add(column.toLowerCase(Locale.ENGLISH)); } indexes.add(ImmutableIndex.of(name, columns)); } return indexes.build(); }
From source file:com.facebook.buck.apple.XcodeRuleConfiguration.java
/** * Convert from a raw json representation of the Configuration to an actual Configuration object. * * @param configurations/*from w ww .ja v a 2s . c om*/ * A map of configuration names to lists, where each each element is a layer of the * configuration. Each layer can be specified as a path to a .xcconfig file, or a dictionary of * xcode build settings. */ public static ImmutableSet<XcodeRuleConfiguration> fromRawJsonStructure( ImmutableMap<String, ImmutableList<Either<Path, ImmutableMap<String, String>>>> configurations) { ImmutableSet.Builder<XcodeRuleConfiguration> builder = ImmutableSet.builder(); for (ImmutableMap.Entry<String, ImmutableList<Either<Path, ImmutableMap<String, String>>>> entry : configurations .entrySet()) { ImmutableList.Builder<Layer> layers = ImmutableList.builder(); for (Either<Path, ImmutableMap<String, String>> value : entry.getValue()) { if (value.isLeft()) { layers.add(new Layer(value.getLeft())); } else if (value.isRight()) { layers.add(new Layer(value.getRight())); } } builder.add(new XcodeRuleConfiguration(entry.getKey(), layers.build())); } return builder.build(); }
From source file:io.prestosql.execution.SqlQueryExecution.java
private static Set<ConnectorId> extractConnectors(Analysis analysis) { ImmutableSet.Builder<ConnectorId> connectors = ImmutableSet.builder(); for (TableHandle tableHandle : analysis.getTables()) { connectors.add(tableHandle.getConnectorId()); }/*from w w w. java 2s . c o m*/ if (analysis.getInsert().isPresent()) { TableHandle target = analysis.getInsert().get().getTarget(); connectors.add(target.getConnectorId()); } return connectors.build(); }
From source file:org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation.java
public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchema augmentation) { final ImmutableSet.Builder<QName> potentialChildren = ImmutableSet.builder(); for (final DataSchemaNode child : augmentation.getChildNodes()) { potentialChildren.add(child.getQName()); }//from www. ja va 2 s. c o m return new AugmentationIdentifier(potentialChildren.build()); }
From source file:org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor.java
/** * Get the events table for an experiment. If all traces in the experiment * are of the same type, use the same behavior as if it was one trace of * that type./*from ww w . java 2s . co m*/ * * @param experiment * the experiment * @param parent * the parent Composite * @param cacheSize * the event table cache size * @return An event table of the appropriate type */ private static @NonNull Iterable<ITmfEventAspect<?>> getExperimentAspects(final TmfExperiment experiment) { List<ITmfTrace> traces = experiment.getTraces(); ImmutableSet.Builder<ITmfEventAspect<?>> builder = new ImmutableSet.Builder<>(); /* For experiments, we'll add a "trace name" aspect/column */ builder.add(TmfBaseAspects.getTraceNameAspect()); String commonTraceType = getCommonTraceType(experiment); if (commonTraceType != null) { /* * All the traces in this experiment are of the same type, let's * just use the normal table for that type. */ builder.addAll(traces.get(0).getEventAspects()); } else { /* * There are different trace types in the experiment, so we are * definitely using a TmfEventsTable. Aggregate the columns from all * trace types. */ for (ITmfTrace trace : traces) { Iterable<ITmfEventAspect<?>> traceAspects = trace.getEventAspects(); builder.addAll(traceAspects); } } return builder.build(); }