List of usage examples for com.google.common.collect ImmutableSet isEmpty
boolean isEmpty();
From source file:com.facebook.buck.doctor.AbstractReport.java
public final Optional<DefectSubmitResult> collectAndSubmitResult() throws IOException, InterruptedException { ImmutableSet<BuildLogEntry> selectedBuilds = promptForBuildSelection(); if (selectedBuilds.isEmpty()) { return Optional.empty(); }//from w ww . ja va 2 s . co m Optional<UserReport> userReport = getUserReport(); Optional<SourceControlInfo> sourceControlInfo = getSourceControlInfo(); ImmutableSet<Path> extraInfoPaths = ImmutableSet.of(); Optional<String> extraInfo = Optional.empty(); try { Optional<ExtraInfoResult> extraInfoResultOptional = extraInfoCollector.run(); if (extraInfoResultOptional.isPresent()) { extraInfoPaths = extraInfoResultOptional.get().getExtraFiles(); extraInfo = Optional.of(extraInfoResultOptional.get().getOutput()); } } catch (ExtraInfoCollector.ExtraInfoExecutionException e) { output.printErrorText("There was a problem gathering additional information: %s. " + "The results will not be attached to the report.", e.getMessage()); } Optional<FileChangesIgnoredReport> fileChangesIgnoredReport = getFileChangesIgnoredReport(); UserLocalConfiguration userLocalConfiguration = UserLocalConfiguration.of(isNoBuckCheckPresent(), getLocalConfigs(), getConfigOverrides(selectedBuilds)); ImmutableSet<Path> includedPaths = FluentIterable.from(selectedBuilds).transformAndConcat(input -> { Builder<Path> result = ImmutableSet.builder(); Optionals.addIfPresent(input.getRuleKeyLoggerLogFile(), result); Optionals.addIfPresent(input.getMachineReadableLogFile(), result); Optionals.addIfPresent(input.getRuleKeyDiagKeysFile(), result); Optionals.addIfPresent(input.getRuleKeyDiagGraphFile(), result); result.add(input.getRelativePath()); return result.build(); }).append(extraInfoPaths).append(userLocalConfiguration.getLocalConfigsContents().keySet()) .append(getTracePathsOfBuilds(selectedBuilds)).append(fileChangesIgnoredReport .flatMap(r -> r.getWatchmanDiagReport()).map(ImmutableList::of).orElse(ImmutableList.of())) .toSet(); DefectReport defectReport = DefectReport.builder().setUserReport(userReport) .setHighlightedBuildIds(RichStream.from(selectedBuilds).map(BuildLogEntry::getBuildId) .flatMap(Optionals::toStream).toOnceIterable()) .setBuildEnvironmentDescription(buildEnvironmentDescription).setSourceControlInfo(sourceControlInfo) .setIncludedPaths(includedPaths).setExtraInfo(extraInfo) .setFileChangesIgnoredReport(fileChangesIgnoredReport) .setUserLocalConfiguration(userLocalConfiguration).build(); output.getStdOut().println("Writing report, please wait..\n"); return Optional.of(defectReporter.submitReport(defectReport)); }
From source file:google.registry.export.CheckSnapshotAction.java
private void checkAndLoadSnapshotIfComplete() { Set<String> kindsToLoad = ImmutableSet.copyOf(Splitter.on(',').split(kindsToLoadParam)); DatastoreBackupInfo backup = getBackup(); // Stop now if the backup is not complete. if (!backup.getStatus().equals(BackupStatus.COMPLETE)) { Duration runningTime = backup.getRunningTime(); if (runningTime.isShorterThan(MAXIMUM_BACKUP_RUNNING_TIME)) { // Backup might still be running, so send a 304 to have the task retry. throw new NotModifiedException(String.format("Datastore backup %s still pending", snapshotName)); } else {/*from w w w . ja v a 2 s .c om*/ // Declare the backup a lost cause, and send 204 No Content so the task will // not be retried. String message = String.format("Datastore backup %s abandoned - not complete after %s", snapshotName, PeriodFormat.getDefault().print(runningTime.toPeriod() .normalizedStandard(PeriodType.dayTime().withMillisRemoved()))); throw new NoContentException(message); } } // Get a compact string to identify this snapshot in BigQuery by trying to parse the unique // suffix out of the snapshot name and falling back to the start time as a string. String snapshotId = snapshotName.startsWith(ExportSnapshotAction.SNAPSHOT_PREFIX) ? snapshotName.substring(ExportSnapshotAction.SNAPSHOT_PREFIX.length()) : backup.getStartTime().toString("YYYYMMdd_HHmmss"); // Log a warning if kindsToLoad is not a subset of the exported snapshot kinds. if (!backup.getKinds().containsAll(kindsToLoad)) { logger.warningfmt("Kinds to load included non-exported kinds: %s", Sets.difference(kindsToLoad, backup.getKinds())); } // Load kinds from the snapshot, limited to those also in kindsToLoad (if it's present). ImmutableSet<String> exportedKindsToLoad = ImmutableSet .copyOf(intersection(backup.getKinds(), kindsToLoad)); String message = String.format("Datastore backup %s complete - ", snapshotName); if (exportedKindsToLoad.isEmpty()) { message += "no kinds to load into BigQuery"; } else { enqueueLoadSnapshotTask(snapshotId, backup.getGcsFilename().get(), exportedKindsToLoad); message += "BigQuery load task enqueued"; } logger.info(message); response.setPayload(message); }
From source file:google.registry.flows.domain.DomainFlowUtils.java
static void validateRegistrantAllowedOnTld(String tld, String registrantContactId) throws RegistrantNotAllowedException { ImmutableSet<String> whitelist = Registry.get(tld).getAllowedRegistrantContactIds(); // Empty whitelist or null registrantContactId are ignored. if (registrantContactId != null && !whitelist.isEmpty() && !whitelist.contains(registrantContactId)) { throw new RegistrantNotAllowedException(registrantContactId); }/*from w w w. ja v a 2 s .co m*/ }
From source file:com.google.javascript.jscomp.newtypes.JSType.java
public static JSType join(JSType lhs, JSType rhs) { Preconditions.checkNotNull(lhs);/* w w w.j a v a 2 s. c om*/ Preconditions.checkNotNull(rhs); if (lhs.isTop() || rhs.isTop()) { return TOP; } else if (lhs.isUnknown() || rhs.isUnknown()) { return UNKNOWN; } else if (lhs.isBottom()) { return rhs; } else if (rhs.isBottom()) { return lhs; } if (lhs.getTypeVar() != null && rhs.getTypeVar() != null && !lhs.getTypeVar().equals(rhs.getTypeVar())) { // For now return ? when joining two type vars. This is probably uncommon. return UNKNOWN; } int newMask = lhs.getMask() | rhs.getMask(); ImmutableSet<ObjectType> newObjs = ObjectType.joinSets(lhs.getObjs(), rhs.getObjs()); String newTypevar = lhs.getTypeVar() != null ? lhs.getTypeVar() : rhs.getTypeVar(); ImmutableSet<EnumType> newEnums = EnumType.union(lhs.getEnums(), rhs.getEnums()); if (newEnums.isEmpty()) { return makeType(newMask, newObjs, newTypevar, ImmutableSet.<EnumType>of()); } JSType tmpJoin = makeType(newMask & ~ENUM_MASK, newObjs, newTypevar, ImmutableSet.<EnumType>of()); return makeType(newMask, newObjs, newTypevar, EnumType.normalizeForJoin(newEnums, tmpJoin)); }
From source file:google.registry.flows.domain.DomainFlowUtils.java
static void validateNameserversCountForTld(String tld, int count) throws EppException { ImmutableSet<String> whitelist = Registry.get(tld).getAllowedFullyQualifiedHostNames(); // For TLDs with a nameserver whitelist, all domains must have at least 1 nameserver. if (!whitelist.isEmpty() && count == 0) { throw new NameserversNotSpecifiedException(); }/* w w w. ja v a 2s. c om*/ if (count > MAX_NAMESERVERS_PER_DOMAIN) { throw new TooManyNameserversException( String.format("Only %d nameservers are allowed per domain", MAX_NAMESERVERS_PER_DOMAIN)); } }
From source file:google.registry.ui.server.registrar.RegistrarSettingsAction.java
Map<String, Object> update(final Map<String, ?> args, final Registrar registrar) { final String clientId = sessionUtils.getRegistrarClientId(request); return ofy().transact(new Work<Map<String, Object>>() { @Override// www . j a v a2s.c om public Map<String, Object> run() { ImmutableSet<RegistrarContact> oldContacts = registrar.getContacts(); Map<String, Object> existingRegistrarMap = expandRegistrarWithContacts(oldContacts, registrar); Registrar.Builder builder = registrar.asBuilder(); ImmutableSet<RegistrarContact> updatedContacts = changeRegistrarFields(registrar, builder, args); if (!updatedContacts.isEmpty()) { builder.setContactsRequireSyncing(true); } Registrar updatedRegistrar = builder.build(); ofy().save().entity(updatedRegistrar); if (!updatedContacts.isEmpty()) { checkContactRequirements(oldContacts, updatedContacts); RegistrarContact.updateContacts(updatedRegistrar, updatedContacts); } // Update the registrar map with updated contacts to bypass Objectify caching issues that // come into play with calling getContacts(). Map<String, Object> updatedRegistrarMap = expandRegistrarWithContacts(updatedContacts, updatedRegistrar); sendExternalUpdatesIfNecessary(updatedRegistrar.getRegistrarName(), existingRegistrarMap, updatedRegistrarMap); return JsonResponseHelper.create(SUCCESS, "Saved " + clientId, updatedRegistrar.toJsonMap()); } }); }
From source file:se.sics.caracaldb.global.CatHerder.java
private void bootstrapJoiners(LUTUpdate update) { ImmutableSet<Address> joiners = update.joiners(); if (joiners.isEmpty()) { return;// ww w . j a va 2 s . c o m } byte[] lutS = lut.serialise(); for (Address addr : joiners) { BootstrapResponse br = new BootstrapResponse(self, addr, lutS); trigger(br, net); outstandingJoins.remove(addr); } }
From source file:com.facebook.buck.thrift.ThriftLibraryDescription.java
@Override public boolean hasFlavors(ImmutableSet<Flavor> flavors) { return enhancers.containsAnyOf(flavors) || flavors.isEmpty(); }
From source file:com.facebook.buck.android.UberRDotJava.java
@Override public List<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); AndroidResourceDetails androidResourceDetails = androidResourceDepsFinder.getAndroidResourceDetails(); ImmutableSet<String> rDotJavaPackages = androidResourceDetails.rDotJavaPackages; ImmutableSet<Path> resDirectories = filteredResourcesProvider.getResDirectories(); if (!resDirectories.isEmpty()) { generateAndCompileRDotJavaFiles(resDirectories, rDotJavaPackages, steps, buildableContext); }//from w ww . j a v a 2 s . com if (rDotJavaNeedsDexing && !resDirectories.isEmpty()) { Path rDotJavaDexDir = getPathToRDotJavaDexFiles(); steps.add(new MakeCleanDirectoryStep(rDotJavaDexDir)); steps.add(new DxStep(getPathToRDotJavaDex(), Collections.singleton(getPathToCompiledRDotJavaFiles()), EnumSet.of(DxStep.Option.NO_OPTIMIZE))); final EstimateLinearAllocStep estimateLinearAllocStep = new EstimateLinearAllocStep( getPathToCompiledRDotJavaFiles()); steps.add(estimateLinearAllocStep); buildableContext.recordArtifact(getPathToRDotJavaDex()); steps.add(new AbstractExecutionStep("record_build_output") { @Override public int execute(ExecutionContext context) { buildableContext.addMetadata(R_DOT_JAVA_LINEAR_ALLOC_SIZE, estimateLinearAllocStep.get().toString()); return 0; } }); } return steps.build(); }
From source file:org.elasticsearch.cluster.block.ClusterBlocks.java
public boolean indexBlocked(ClusterBlockLevel level, String index) { if (!global(level).isEmpty()) { return true; }//from w w w. j a v a2 s.com ImmutableSet<ClusterBlock> indexBlocks = indices(level).get(index); if (indexBlocks != null && !indexBlocks.isEmpty()) { return true; } return false; }