List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:io.flutter.utils.FileWatch.java
/** * Starts watching some paths beneath a VirtualFile. * * <p>Each path is relative to the VirtualFile and need not exist. * * @param callback will be run asynchronously sometime after the file changed. */// ww w . j a v a 2s .c om public static @NotNull FileWatch subscribe(@NotNull VirtualFile base, @NotNull Iterable<String> paths, @NotNull Runnable callback) { final ImmutableSet.Builder<Location> builder = ImmutableSet.builder(); for (String path : paths) { builder.add(new Location(base, path)); } final FileWatch watcher = new FileWatch(builder.build(), callback); subscriptions.subscribe(watcher); return watcher; }
From source file:com.google.auto.factory.processor.Parameter.java
static Parameter forVariableElement(VariableElement variable, TypeMirror type) { ImmutableSet.Builder<String> qualifiers = ImmutableSet.builder(); for (AnnotationMirror annotationMirror : variable.getAnnotationMirrors()) { DeclaredType annotationType = annotationMirror.getAnnotationType(); if (annotationType.asElement().getAnnotation(Qualifier.class) != null) { qualifiers.add(Mirrors.getQualifiedName(annotationType).toString()); }/* w ww.j a v a 2 s. c om*/ } // TODO(gak): check for only one qualifier rather than using the first return new Parameter(FluentIterable.from(qualifiers.build()).first(), type.toString(), variable.getSimpleName().toString()); }
From source file:com.facebook.buck.apple.toolchain.impl.ProvisioningProfileMetadataFactory.java
public static ProvisioningProfileMetadata fromProvisioningProfilePath(ProcessExecutor executor, ImmutableList<String> readCommand, Path profilePath) throws IOException, InterruptedException { Set<Option> options = EnumSet.of(Option.EXPECTING_STD_OUT); // Extract the XML from its signed message wrapper. ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addAllCommand(readCommand) .addCommand(profilePath.toString()).build(); ProcessExecutor.Result result; result = executor.launchAndExecute(processExecutorParams, options, /* stdin */ Optional.empty(), /* timeOutMs */ Optional.empty(), /* timeOutHandler */ Optional.empty()); if (result.getExitCode() != 0) { throw new IOException(result.getMessageForResult("Invalid provisioning profile: " + profilePath)); }// ww w . j a v a2 s.co m try { NSDictionary plist = (NSDictionary) PropertyListParser.parse(result.getStdout().get().getBytes()); Date expirationDate = ((NSDate) plist.get("ExpirationDate")).getDate(); String uuid = ((NSString) plist.get("UUID")).getContent(); ImmutableSet.Builder<HashCode> certificateFingerprints = ImmutableSet.builder(); NSArray certificates = (NSArray) plist.get("DeveloperCertificates"); HashFunction hasher = Hashing.sha1(); if (certificates != null) { for (NSObject item : certificates.getArray()) { certificateFingerprints.add(hasher.hashBytes(((NSData) item).bytes())); } } ImmutableMap.Builder<String, NSObject> builder = ImmutableMap.builder(); NSDictionary entitlements = ((NSDictionary) plist.get("Entitlements")); for (String key : entitlements.keySet()) { builder = builder.put(key, entitlements.objectForKey(key)); } String appID = entitlements.get("application-identifier").toString(); ProvisioningProfileMetadata.Builder provisioningProfileMetadata = ProvisioningProfileMetadata.builder(); if (plist.get("Platform") != null) { for (Object platform : (Object[]) plist.get("Platform").toJavaObject()) { provisioningProfileMetadata.addPlatforms((String) platform); } } return provisioningProfileMetadata.setAppID(ProvisioningProfileMetadata.splitAppID(appID)) .setExpirationDate(expirationDate).setUUID(uuid).setProfilePath(profilePath) .setEntitlements(builder.build()) .setDeveloperCertificateFingerprints(certificateFingerprints.build()).build(); } catch (Exception e) { throw new IllegalArgumentException("Malformed embedded plist: " + e); } }
From source file:org.jclouds.googlecompute.compute.functions.MachineTypeToHardware.java
private Iterable<Volume> collectVolumes(MachineType input) { ImmutableSet.Builder<Volume> volumes = ImmutableSet.builder(); for (MachineType.EphemeralDisk disk : input.getEphemeralDisks()) { volumes.add(new VolumeImpl(null, Volume.Type.LOCAL, new Integer(disk.getDiskGb()).floatValue(), null, true, false));/* w w w . j a v a 2 s .c o m*/ } return volumes.build(); }
From source file:com.android.build.gradle.internal.dsl.DensitySplitOptions.java
@Override protected ImmutableSet<String> getAllowedValues() { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (Density value : Density.values()) { if (value != Density.NODPI && value != Density.ANYDPI) { builder.add(value.getResourceValue()); }//w w w . j a v a 2s .com } return builder.build(); }
From source file:com.stackframe.sarariman.ContactsGlobalAudit.java
private Set<Contact> projectInvoiceContacts() throws SQLException { try (Connection connection = dataSource.getConnection(); PreparedStatement ps = connection.prepareStatement("SELECT contact FROM project_invoice_contacts"); ResultSet rs = ps.executeQuery();) { ImmutableSet.Builder<Contact> setBuilder = ImmutableSet.<Contact>builder(); while (rs.next()) { setBuilder.add(contacts.get(rs.getInt("contact"))); }// w w w.j a v a2s .co m return setBuilder.build(); } }
From source file:co.cask.tigon.internal.app.queue.AbstractQueueSpecificationGenerator.java
/** * Finds a equal or compatible schema connection between <code>source</code> and <code>target</code> * flowlet.//ww w . j a va 2s. co m */ protected Set<QueueSpecification> generateQueueSpecification(String flow, FlowletConnection connection, Map<String, Set<Schema>> inputSchemas, Map<String, Set<Schema>> outputSchemas) { ImmutableSet.Builder<QueueSpecification> builder = ImmutableSet.builder(); // Iterate through all the outputs and look for an input with compatible schema. // If no such input is found, look for one with ANY_INPUT. // If there is exact match of schema then we pick that over the compatible one. for (Map.Entry<String, Set<Schema>> entryOutput : outputSchemas.entrySet()) { String outputName = entryOutput.getKey(); Set<Schema> nameOutputSchemas = inputSchemas.get(outputName); ImmutablePair<Schema, Schema> schemas = (nameOutputSchemas == null) ? null : SchemaFinder.findSchema(entryOutput.getValue(), nameOutputSchemas); if (schemas == null) { // Try ANY_INPUT Set<Schema> anyInputSchemas = inputSchemas.get(FlowletDefinition.ANY_INPUT); if (anyInputSchemas != null) { schemas = SchemaFinder.findSchema(entryOutput.getValue(), anyInputSchemas); } } if (schemas == null) { continue; } if (connection.getSourceType() == FlowletConnection.Type.STREAM) { builder.add(createSpec(QueueName.fromStream(outputName), schemas.getFirst(), schemas.getSecond())); } else { builder.add(createSpec(QueueName.fromFlowlet(flow, flow, connection.getSourceName(), outputName), schemas.getFirst(), schemas.getSecond())); } } return builder.build(); }
From source file:com.facebook.presto.sql.planner.SymbolExtractor.java
public static Set<Symbol> extract(PlanNode node) { ImmutableSet.Builder<Symbol> builder = ImmutableSet.builder(); node.accept(new Visitor(builder), null); return builder.build(); }
From source file:be.dnsbelgium.rdap.core.Link.java
@JsonCreator public Link(@JsonProperty("value") URI value, @JsonProperty("rel") String rel, @JsonProperty("href") URI href, @JsonProperty("hreflang") Set<String> hreflang, @JsonProperty("title") List<String> title, @JsonProperty("media") String media, @JsonProperty("type") String type) { if (href == null) { throw new IllegalArgumentException("href MUST be specified"); }//from w w w . j a v a 2 s . c om this.value = value; this.rel = rel; this.href = href; this.hreflang = (hreflang == null) ? null : new ImmutableSet.Builder<String>().addAll(hreflang).build(); this.title = (title == null) ? null : new ImmutableList.Builder<String>().addAll(title).build(); this.media = media; this.type = type; }
From source file:org.apache.cassandra.utils.DirectorySizeCalculator.java
public DirectorySizeCalculator(List<File> files) { super();// w w w . j a v a2 s . com this.path = null; ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (File file : files) builder.add(file.getName()); alive = builder.build(); }