com.google.common.collect.ImmutableSet#isEmpty ( )源码实例Demo

下面列出了com.google.common.collect.ImmutableSet#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: buck   文件: ResolveAliasHelper.java
/**
 * Assumes each argument passed to this command is an alias defined in .buckconfig, or a fully
 * qualified (non-alias) target to be verified by checking the build files. Prints the build
 * target that each alias maps to on its own line to standard out.
 */
public static void resolveAlias(
    CommandRunnerParams params, PerBuildState parserState, List<String> aliases) {

  List<String> resolvedAliases = new ArrayList<>();
  for (String alias : aliases) {
    ImmutableSet<String> buildTargets;
    if (alias.contains("//")) {
      String buildTarget = validateBuildTargetForFullyQualifiedTarget(params, alias, parserState);
      if (buildTarget == null) {
        throw new HumanReadableException("%s is not a valid target.", alias);
      }
      buildTargets = ImmutableSet.of(buildTarget);
    } else {
      buildTargets = getBuildTargetForAlias(params.getBuckConfig(), alias);
      if (buildTargets.isEmpty()) {
        throw new HumanReadableException("%s is not an alias.", alias);
      }
    }
    resolvedAliases.addAll(buildTargets);
  }

  for (String resolvedAlias : resolvedAliases) {
    params.getConsole().getStdOut().println(resolvedAlias);
  }
}
 
源代码2 项目: intellij   文件: PendingChangesHandler.java
/**
 * Run task if there have been no more changes since it was first requested, otherwise queue up
 * another task.
 */
private void timerComplete() {
  Duration timeSinceLastEvent = Duration.between(lastChangeTime, Instant.now());
  Duration timeToWait = delayDuration.minus(timeSinceLastEvent);
  if (!timeToWait.isNegative()) {
    // kick off another task and abort this one
    queueTask(timeToWait);
    return;
  }
  ImmutableSet<V> items = retrieveAndClearPendingItems();
  if (items.isEmpty()) {
    return;
  }
  if (runTask(items)) {
    isTaskPending.set(false);
  } else {
    pendingItems.addAll(items);
    queueTask(RETRY_DELAY);
  }
}
 
源代码3 项目: bazel   文件: StarlarkProviderValidationUtil.java
public static void validateArtifacts(RuleContext ruleContext) throws EvalException {
  ImmutableSet<Artifact> treeArtifactsConflictingWithFiles =
      ruleContext.getAnalysisEnvironment().getTreeArtifactsConflictingWithFiles();
  if (!treeArtifactsConflictingWithFiles.isEmpty()) {
    throw new EvalException(
        null,
        "The following directories were also declared as files:\n"
            + artifactsDescription(treeArtifactsConflictingWithFiles));
  }

  ImmutableSet<Artifact> orphanArtifacts =
      ruleContext.getAnalysisEnvironment().getOrphanArtifacts();
  if (!orphanArtifacts.isEmpty()) {
    throw new EvalException(
        null,
        "The following files have no generating action:\n"
            + artifactsDescription(orphanArtifacts));
  }
}
 
源代码4 项目: bundletool   文件: StandaloneApkSerializer.java
private static ModuleSplit splitWithOnlyManifest(ModuleSplit split) {
  ModuleSplit stubSplit =
      ModuleSplit.builder()
          .setModuleName(split.getModuleName())
          .setSplitType(split.getSplitType())
          .setVariantTargeting(split.getVariantTargeting())
          .setApkTargeting(split.getApkTargeting())
          .setAndroidManifest(split.getAndroidManifest())
          .setMasterSplit(split.isMasterSplit())
          .build();
  ImmutableSet<Abi> abis = getTargetedAbis(split);
  if (abis.isEmpty()) {
    return stubSplit;
  }
  // Inject native library place holders into the stub
  AbiPlaceholderInjector abiPlaceholderInjector = new AbiPlaceholderInjector(abis);
  ModuleSplit result = abiPlaceholderInjector.addPlaceholderNativeEntries(stubSplit);
  return result;
}
 
@Override
protected String doIt()
{
	final ImmutableSet<ShipmentScheduleId> shipmentScheduleIds = getSelectedShipmentScheduleIds();
	if (shipmentScheduleIds.isEmpty())
	{
		throw new AdempiereException("@[email protected]");
	}

	final ViewId viewId = viewsFactory.createView(CreateViewRequest.builder(ShipmentCandidatesViewFactory.WINDOWID)
			.setFilterOnlyIds(ShipmentScheduleId.toIntSet(shipmentScheduleIds))
			.build())
			.getViewId();

	getResult().setWebuiViewToOpen(WebuiViewToOpen.builder()
			.viewId(viewId.getViewId())
			.target(ViewOpenTarget.ModalOverlay)
			.build());

	return MSG_OK;
}
 
源代码6 项目: buck   文件: IjProjectTemplateDataPreparer.java
private void addAndroidAssetPaths(
    Map<String, Object> androidProperties, IjModule module, IjModuleAndroidFacet androidFacet) {
  if (androidFacet.isAndroidLibrary()) {
    return;
  }
  ImmutableSet<Path> assetPaths = androidFacet.getAssetPaths();
  if (assetPaths.isEmpty()) {
    return;
  }
  Set<Path> relativeAssetPaths = new HashSet<>(assetPaths.size());
  for (Path assetPath : assetPaths) {
    relativeAssetPaths.add(projectPaths.getModuleRelativePath(assetPath, module));
  }
  androidProperties.put(
      ASSETS_FOLDER_TEMPLATE_PARAMETER, "/" + Joiner.on(";/").join(relativeAssetPaths));
}
 
private Stream<HUEditorRow> streamByIds(@NonNull final HUEditorRowFilter filter)
{
	final Stream<HUEditorRowId> huEditorRowIds;
	final ImmutableSet<HUEditorRowId> onlyRowIds = filter.getOnlyRowIds();
	if (onlyRowIds.isEmpty())
	{
		final DocumentQueryOrderByList defaultOrderBys = getDefaultSelection().getOrderBys();
		huEditorRowIds = streamHUIdsByPage(0, Integer.MAX_VALUE, defaultOrderBys)
				.map(HUEditorRowId::ofTopLevelHU);
	}
	else
	{
		huEditorRowIds = onlyRowIds.stream();
	}

	return HUEditorRowsPagedLoadingIterator.builder()
			.huEditorRepo(huEditorRepo)
			.cache(cache_huRowsById)
			.rowIds(huEditorRowIds.iterator())
			.filter(filter)
			.build()
			.stream();
}
 
源代码8 项目: bundletool   文件: AbstractSizeAggregator.java
protected ImmutableSet<TextureCompressionFormatTargeting>
    getAllTextureCompressionFormatTargetings(ImmutableList<ApkDescription> apkDescriptions) {
  ImmutableSet<TextureCompressionFormatTargeting> textureCompressionFormatTargetingOptions;

  if (isTextureCompressionFormatMissing(getSizeRequest.getDeviceSpec())) {
    textureCompressionFormatTargetingOptions =
        apkDescriptions.stream()
            .map(ApkDescription::getTargeting)
            .filter(ApkTargeting::hasTextureCompressionFormatTargeting)
            .map(ApkTargeting::getTextureCompressionFormatTargeting)
            .collect(toImmutableSet());
  } else {
    textureCompressionFormatTargetingOptions = ImmutableSet.of();
  }
  // Adding default targeting (if targetings are empty) to help computing the cartesian product
  // across all targetings.
  return textureCompressionFormatTargetingOptions.isEmpty()
      ? ImmutableSet.of(TextureCompressionFormatTargeting.getDefaultInstance())
      : textureCompressionFormatTargetingOptions;
}
 
源代码9 项目: nomulus   文件: DomainInfoFlow.java
private ImmutableList<ResponseExtension> getDomainResponseExtensions(
    DomainBase domain, DateTime now) throws EppException {
  ImmutableList.Builder<ResponseExtension> extensions = new ImmutableList.Builder<>();
  addSecDnsExtensionIfPresent(extensions, domain.getDsData());
  ImmutableSet<GracePeriodStatus> gracePeriodStatuses = domain.getGracePeriodStatuses();
  if (!gracePeriodStatuses.isEmpty()) {
    extensions.add(RgpInfoExtension.create(gracePeriodStatuses));
  }
  Optional<FeeInfoCommandExtensionV06> feeInfo =
      eppInput.getSingleExtension(FeeInfoCommandExtensionV06.class);
  if (feeInfo.isPresent()) { // Fee check was requested.
    FeeInfoResponseExtensionV06.Builder builder = new FeeInfoResponseExtensionV06.Builder();
    handleFeeRequest(
        feeInfo.get(),
        builder,
        InternetDomainName.from(targetId),
        Optional.of(domain),
        null,
        now,
        pricingLogic,
        Optional.empty(),
        false);
    extensions.add(builder.build());
  }
  return extensions.build();
}
 
/**
 * @return true if at least one HU was removed
 */
private boolean removeHUsIfDestroyed(final Collection<HuId> huIds)
{
	final ImmutableSet<HuId> destroyedHUIds = huIds.stream()
			.distinct()
			.map(huId -> load(huId, I_M_HU.class))
			.filter(Services.get(IHandlingUnitsBL.class)::isDestroyed)
			.map(I_M_HU::getM_HU_ID)
			.map(HuId::ofRepoId)
			.collect(ImmutableSet.toImmutableSet());
	if (destroyedHUIds.isEmpty())
	{
		return false;
	}

	final HUEditorView view = getView();
	final boolean changes = view.removeHUIds(destroyedHUIds);
	return changes;
}
 
public static DocumentIdsSelection ofStringSet(final Collection<String> stringDocumentIds)
{
	if (stringDocumentIds == null || stringDocumentIds.isEmpty())
	{
		return EMPTY;
	}

	final ImmutableSet.Builder<DocumentId> documentIdsBuilder = ImmutableSet.builder();
	for (final String documentIdStr : stringDocumentIds)
	{
		if (ALL_String.equals(documentIdStr))
		{
			return ALL;
		}

		documentIdsBuilder.add(DocumentId.of(documentIdStr));
	}

	final ImmutableSet<DocumentId> documentIds = documentIdsBuilder.build();
	if (documentIds.isEmpty())
	{
		return EMPTY;
	}
	return new DocumentIdsSelection(false, documentIds);
}
 
源代码12 项目: tac-kbp-eal   文件: _DocLevelArgLinking.java
public final DocLevelArgLinking filterArguments(
    Predicate<? super DocLevelEventArg> argPredicate) {
  final DocLevelArgLinking.Builder ret = DocLevelArgLinking.builder()
      .docID(docID());
  for (final ScoringEventFrame eventFrame : eventFrames()) {
    final ImmutableSet<DocLevelEventArg> filteredFrame =
        FluentIterable.from(eventFrame).filter(argPredicate).toSet();
    if (!filteredFrame.isEmpty()) {
      ret.addEventFrames(ScoringEventFrame.of(filteredFrame));
    }
  }
  return ret.build();
}
 
源代码13 项目: bazel   文件: License.java
public static License of(Collection<LicenseType> licenses, Collection<Label> exceptions) {
  ImmutableSet<LicenseType> licenseSet = ImmutableSet.copyOf(licenses);
  ImmutableSet<Label> exceptionSet = ImmutableSet.copyOf(exceptions);

  if (exceptionSet.isEmpty() && licenseSet.equals(ImmutableSet.of(LicenseType.NONE))) {
    return License.NO_LICENSE;
  }

  return new License(licenseSet, exceptionSet);
}
 
源代码14 项目: bundletool   文件: BundleConfigValidator.java
private void validateMasterResources(BundleConfig bundleConfig, AppBundle bundle) {
  ImmutableSet<Integer> resourcesToBePinned =
      ImmutableSet.copyOf(bundleConfig.getMasterResources().getResourceIdsList());
  if (resourcesToBePinned.isEmpty()) {
    return;
  }

  ImmutableSet<Integer> allResourceIds =
      bundle.getFeatureModules().values().stream()
          .map(BundleModule::getResourceTable)
          .filter(Optional::isPresent)
          .map(Optional::get)
          .flatMap(resourceTable -> ResourcesUtils.entries(resourceTable))
          .map(ResourceTableEntry::getResourceId)
          .map(ResourceId::getFullResourceId)
          .collect(toImmutableSet());

  SetView<Integer> undefinedResources = Sets.difference(resourcesToBePinned, allResourceIds);

  if (!undefinedResources.isEmpty()) {
    throw InvalidBundleException.builder()
        .withUserMessage(
            "Error in BundleConfig. The Master Resources list contains resource IDs not defined "
                + "in any module. For example: 0x%08x",
            undefinedResources.iterator().next())
        .build();
  }
}
 
源代码15 项目: buck   文件: BuildCommand.java
protected BuildRunResult run(
    CommandRunnerParams params,
    CommandThreadManager commandThreadManager,
    Function<ImmutableList<TargetNodeSpec>, ImmutableList<TargetNodeSpec>> targetNodeSpecEnhancer,
    ImmutableSet<String> additionalTargets)
    throws Exception {
  if (showOutput) {
    CommandHelper.maybePrintShowOutputWarning(
        params.getBuckConfig().getView(CliConfig.class),
        params.getConsole().getAnsi(),
        params.getBuckEventBus());
  }
  if (!additionalTargets.isEmpty()) {
    this.arguments.addAll(additionalTargets);
  }
  BuildEvent.Started started = postBuildStartedEvent(params);
  BuildRunResult result = ImmutableBuildRunResult.of(ExitCode.BUILD_ERROR, ImmutableList.of());
  try {
    result = executeBuildAndProcessResult(params, commandThreadManager, targetNodeSpecEnhancer);
  } catch (ActionGraphCreationException e) {
    params.getConsole().printBuildFailure(e.getMessage());
    result = ImmutableBuildRunResult.of(ExitCode.PARSE_ERROR, ImmutableList.of());
  } finally {
    params.getBuckEventBus().post(BuildEvent.finished(started, result.getExitCode()));
  }

  return result;
}
 
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable()
{
	final ImmutableSet<PaymentId> paymentIds = getSelectedPaymentIds();
	if (paymentIds.isEmpty())
	{
		return ProcessPreconditionsResolution.rejectBecauseNoSelection().toInternal();
	}

	return ProcessPreconditionsResolution.accept();
}
 
源代码17 项目: buck   文件: AuditFlavorsCommand.java
private void printFlavors(ImmutableList<TargetNode<?>> targetNodes, CommandRunnerParams params) {
  DirtyPrintStreamDecorator stdout = params.getConsole().getStdOut();
  for (TargetNode<?> node : targetNodes) {
    BaseDescription<?> description = node.getDescription();
    stdout.println(node.getBuildTarget().getFullyQualifiedName());
    if (description instanceof Flavored) {
      Optional<ImmutableSet<FlavorDomain<?>>> flavorDomains =
          ((Flavored) description).flavorDomains(node.getBuildTarget().getTargetConfiguration());
      if (flavorDomains.isPresent()) {
        for (FlavorDomain<?> domain : flavorDomains.get()) {
          ImmutableSet<UserFlavor> userFlavors =
              RichStream.from(domain.getFlavors().stream())
                  .filter(UserFlavor.class)
                  .collect(ImmutableSet.toImmutableSet());
          if (userFlavors.isEmpty()) {
            continue;
          }
          stdout.printf(" %s\n", domain.getName());
          for (UserFlavor flavor : userFlavors) {
            String flavorLine = String.format("  %s", flavor.getName());
            String flavorDescription = flavor.getDescription();
            if (flavorDescription.length() > 0) {
              flavorLine += String.format(" -> %s", flavorDescription);
            }
            flavorLine += "\n";
            stdout.printf(flavorLine);
          }
        }
      } else {
        stdout.println(" unknown");
      }
    } else {
      stdout.println(" no flavors");
    }
  }
}
 
源代码18 项目: onos   文件: FlowRuleOperations.java
/**
 * Closes the current stage.
 */
private void closeStage() {
    ImmutableSet<FlowRuleOperation> stage = currentStage.build();
    if (!stage.isEmpty()) {
        listBuilder.add(stage);
    }
}
 
源代码19 项目: tac-kbp-eal   文件: LinkingWriter2016.java
private String getEventFrameID(final ResponseSet responseSet,
    final ResponseLinking responseLinking) throws IOException {
  checkArgument(responseLinking.responseSetIds().isPresent(), "Linking does not assign frame "
      + "IDs. These are required for writing in 2016 format.");
  final ImmutableSet<String> ids =
      responseLinking.responseSetIds().get().asMultimap().inverse().get(responseSet);
  if (ids.size() == 1) {
    return ids.asList().get(0);
  } else if (ids.isEmpty()) {
    throw new IOException("No ID found for event frame " + responseSet);
  } else {
    throw new IOException("Multiple IDs found for event frame, should be impossible: "
        + responseSet);
  }
}
 
源代码20 项目: buck   文件: XCodeProjectCommandHelper.java
/** Run xcode specific project generation actions. */
private ExitCode runXcodeProjectGenerator(
    TargetGraphCreationResult targetGraphCreationResult,
    Optional<ImmutableMap<BuildTarget, TargetNode<?>>> sharedLibraryToBundle)
    throws IOException, InterruptedException {
  ExitCode exitCode = ExitCode.SUCCESS;
  AppleConfig appleConfig = buckConfig.getView(AppleConfig.class);
  ProjectGeneratorOptions options =
      ProjectGeneratorOptions.builder()
          .setShouldGenerateReadOnlyFiles(readOnly)
          .setShouldIncludeTests(isWithTests(buckConfig))
          .setShouldIncludeDependenciesTests(isWithDependenciesTests(buckConfig))
          .setShouldAddLinkedLibrariesAsFlags(appleConfig.shouldAddLinkedLibrariesAsFlags())
          .setShouldForceLoadLinkWholeLibraries(
              appleConfig.shouldAddLinkerFlagsForLinkWholeLibraries())
          .setShouldGenerateMissingUmbrellaHeader(
              appleConfig.shouldGenerateMissingUmbrellaHeaders())
          .setShouldUseShortNamesForTargets(true)
          .setShouldGenerateProjectSchemes(createProjectSchemes)
          .build();

  LOG.debug("Xcode project generation: Generates workspaces for targets");

  ImmutableList<Result> results =
      generateWorkspacesForTargets(
          buckEventBus,
          pluginManager,
          cell,
          buckConfig,
          ruleKeyConfiguration,
          executorService,
          targetGraphCreationResult,
          options,
          appleCxxFlavors,
          focusedTargetMatcher,
          sharedLibraryToBundle);
  ImmutableSet<BuildTarget> requiredBuildTargets =
      results.stream()
          .flatMap(b -> b.getBuildTargets().stream())
          .collect(ImmutableSet.toImmutableSet());
  if (!requiredBuildTargets.isEmpty()) {
    ImmutableList<String> arguments =
        RichStream.from(requiredBuildTargets)
            .map(
                target -> {
                  // TODO(T47190884): Use our NewCellPathResolver to look up the path.
                  if (!target.getCell().equals(cell.getCanonicalName())) {
                    CanonicalCellName cellName = target.getCell();

                    return target.withUnflavoredBuildTarget(
                        UnflavoredBuildTarget.of(
                            cellName, target.getBaseName(), target.getShortName()));
                  } else {
                    return target;
                  }
                })
            .map(Object::toString)
            .toImmutableList();
    exitCode = buildRunner.apply(arguments);
  }

  // Write all output paths to stdout if requested.
  // IMPORTANT: this shuts down RenderingConsole since it writes to stdout.
  // (See DirtyPrintStreamDecorator and note how RenderingConsole uses it.)
  // Thus this must be the *last* thing we do, or we disable progress UI.
  //
  // This is still not the "right" way to do this; we should probably use
  // RenderingConsole#printToStdOut since it ensures we do one last render.
  for (Result result : results) {
    outputPresenter.present(
        result.inputTarget.getFullyQualifiedName(), result.outputRelativePath);
  }

  return exitCode;
}