Java Code Examples for com.google.common.collect.ImmutableSet#isEmpty()
The following examples show how to use
com.google.common.collect.ImmutableSet#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PendingChangesHandler.java From intellij with Apache License 2.0 | 6 votes |
/** * 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); } }
Example 2
Source File: StarlarkProviderValidationUtil.java From bazel with Apache License 2.0 | 6 votes |
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)); } }
Example 3
Source File: ResolveAliasHelper.java From buck with Apache License 2.0 | 6 votes |
/** * 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); } }
Example 4
Source File: StandaloneApkSerializer.java From bundletool with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: ShipmentCandidatesView_Launcher.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 6 votes |
@Override protected String doIt() { final ImmutableSet<ShipmentScheduleId> shipmentScheduleIds = getSelectedShipmentScheduleIds(); if (shipmentScheduleIds.isEmpty()) { throw new AdempiereException("@NoSelection@"); } 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; }
Example 6
Source File: DocumentIdsSelection.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 6 votes |
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); }
Example 7
Source File: IjProjectTemplateDataPreparer.java From buck with Apache License 2.0 | 6 votes |
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)); }
Example 8
Source File: WEBUI_M_HU_Transform.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 6 votes |
/** * @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; }
Example 9
Source File: HUEditorViewBuffer_HighVolume.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 6 votes |
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(); }
Example 10
Source File: AbstractSizeAggregator.java From bundletool with Apache License 2.0 | 6 votes |
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; }
Example 11
Source File: DomainInfoFlow.java From nomulus with Apache License 2.0 | 6 votes |
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(); }
Example 12
Source File: LinkingWriter2016.java From tac-kbp-eal with MIT License | 5 votes |
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); } }
Example 13
Source File: FlowRuleOperations.java From onos with Apache License 2.0 | 5 votes |
/** * Closes the current stage. */ private void closeStage() { ImmutableSet<FlowRuleOperation> stage = currentStage.build(); if (!stage.isEmpty()) { listBuilder.add(stage); } }
Example 14
Source File: AuditFlavorsCommand.java From buck with Apache License 2.0 | 5 votes |
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"); } } }
Example 15
Source File: PaymentView_Launcher_FromPayment.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
@Override protected ProcessPreconditionsResolution checkPreconditionsApplicable() { final ImmutableSet<PaymentId> paymentIds = getSelectedPaymentIds(); if (paymentIds.isEmpty()) { return ProcessPreconditionsResolution.rejectBecauseNoSelection().toInternal(); } return ProcessPreconditionsResolution.accept(); }
Example 16
Source File: BuildCommand.java From buck with Apache License 2.0 | 5 votes |
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; }
Example 17
Source File: BundleConfigValidator.java From bundletool with Apache License 2.0 | 5 votes |
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(); } }
Example 18
Source File: License.java From bazel with Apache License 2.0 | 5 votes |
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); }
Example 19
Source File: _DocLevelArgLinking.java From tac-kbp-eal with MIT License | 5 votes |
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(); }
Example 20
Source File: XCodeProjectCommandHelper.java From buck with Apache License 2.0 | 4 votes |
/** 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; }