List of usage examples for com.google.common.collect ImmutableList isEmpty
boolean isEmpty();
From source file:com.google.cloud.firestore.ResourcePath.java
/** * The Path's id (last component).// w w w . j ava2 s. com * * @return The last component of the Path or null if the path points to the root. */ @Nullable String getId() { ImmutableList<String> parts = getSegments(); if (!parts.isEmpty()) { return parts.get(parts.size() - 1); } else { return null; } }
From source file:com.github.hilcode.versionator.impl.DefaultFlagExtractor.java
@Override public Result<String, Flags> extract(final ImmutableList<String> arguments) { Preconditions.checkNotNull(arguments, "Missing 'arguments'."); if (arguments.isEmpty()) { return Result.failure("No arguments provided.\n\nPerhaps try --help?"); } else {/*from ww w .j ava 2 s. c o m*/ final ImmutableList.Builder<String> expandedArgumentsBuilder = ImmutableList.builder(); for (final String argument : arguments) { if (argument.startsWith("-") && !argument.startsWith("--") && argument.length() > 2) { for (int i = 1; i < argument.length(); i++) { expandedArgumentsBuilder.add("-" + argument.charAt(i)); } } else { expandedArgumentsBuilder.add(argument); } } return extractFlags(expandedArgumentsBuilder.build()); } }
From source file:org.glowroot.agent.impl.UserProfileScheduler.java
void maybeScheduleUserProfiling(Transaction transaction, String user) { UserRecordingConfig userRecordingConfig = configService.getUserRecordingConfig(); ImmutableList<String> users = userRecordingConfig.users(); if (users.isEmpty()) { return;//from ww w.j a va 2 s . c o m } if (!containsIgnoreCase(users, user)) { return; } // for now lumping user recording into slow traces tab transaction.setSlowThresholdMillis(0, Priority.CORE_MAX); // schedule the first stack collection for configured interval after transaction start (or // immediately, if the transaction's total time already exceeds configured collection // interval) Integer intervalMillis = userRecordingConfig.profilingIntervalMillis(); if (intervalMillis == null || intervalMillis <= 0) { return; } if (backgroundExecutor == null) { return; } UserProfileRunnable userProfileRunnable = new UserProfileRunnable(transaction, intervalMillis); userProfileRunnable.scheduleFirst(); transaction.setUserProfileRunnable(userProfileRunnable); }
From source file:com.google.idea.blaze.base.projectview.section.ListSectionParser.java
@Nullable @Override//from w w w . j a v a 2 s . c om public final ListSection<T> parse(ProjectViewParser parser, ParseContext parseContext) { if (parseContext.atEnd()) { return null; } String name = getName(); if (!parseContext.current().text.equals(name + ':')) { return null; } parseContext.consume(); ImmutableList.Builder<ItemOrTextBlock<T>> builder = ImmutableList.builder(); boolean correctIndentationRun = true; List<ItemOrTextBlock<T>> savedTextBlocks = Lists.newArrayList(); while (!parseContext.atEnd()) { boolean isIndented = parseContext.current().indent == SectionParser.INDENT; if (!isIndented && correctIndentationRun) { parseContext.savePosition(); } correctIndentationRun = isIndented; ItemOrTextBlock<T> itemOrTextBlock = null; TextBlock textBlock = TextBlockSection.parseTextBlock(parseContext); if (textBlock != null) { itemOrTextBlock = new ItemOrTextBlock<>(textBlock); } else if (isIndented) { T item = parseItem(parser, parseContext); if (item != null) { parseContext.consume(); itemOrTextBlock = new ItemOrTextBlock<>(item); } } if (itemOrTextBlock == null) { break; } if (isIndented) { builder.addAll(savedTextBlocks); builder.add(itemOrTextBlock); savedTextBlocks.clear(); parseContext.clearSavedPosition(); } else { savedTextBlocks.add(new ItemOrTextBlock<>(textBlock)); } } parseContext.resetToSavedPosition(); ImmutableList<ItemOrTextBlock<T>> items = builder.build(); if (items.isEmpty()) { parseContext.addError(String.format("Empty section: '%s'", name)); } return new ListSection<>(key, items); }
From source file:google.registry.tools.GetApplicationIdsCommand.java
@Override public void run() { for (String domainName : mainParameters) { InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(domainName)); assertTldExists(tld.toString()); System.out.printf("%s:%n", domainName); // Sample output: // example.tld: // 1 (NewRegistrar) // 2 (OtherRegistrar) // example2.tld: // No applications exist for 'example2.tld'. ImmutableList<DomainApplication> applications = ImmutableList .copyOf(loadActiveApplicationsByDomainName(domainName, DateTime.now(UTC))); if (applications.isEmpty()) { System.out.printf(" No applications exist for \'%s\'.%n", domainName); } else {/*ww w.j a v a 2 s . com*/ for (DomainApplication application : applications) { System.out.printf(" %s (%s)%n", application.getForeignKey(), application.getCurrentSponsorClientId()); } } } }
From source file:no.ssb.vtl.script.operations.KeepOperation.java
@Override public Stream<DataPoint> getData() { ImmutableList<Component> componentsToRemove = getComponentsToRemove(); // Optimization. if (componentsToRemove.isEmpty()) return getChild().getData(); // Compute indexes to remove (in reverse order to avoid shifting). final ImmutableSet<Integer> indexes = computeIndexes(componentsToRemove); return getChild().getData().peek(dataPoints -> { for (Integer index : indexes) dataPoints.remove((int) index); });/*from w w w.ja v a2 s . c o m*/ }
From source file:org.gradle.internal.execution.impl.steps.SkipUpToDateStep.java
@Override public UpToDateResult execute(C context) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Determining if {} is up-to-date", context.getWork().getDisplayName()); }//from w w w. j a v a2 s.c om return context.getWork().getChangesSincePreviousExecution().map(changes -> { ImmutableList.Builder<String> builder = ImmutableList.builder(); MessageCollectingChangeVisitor visitor = new MessageCollectingChangeVisitor(builder, 3); changes.visitAllChanges(visitor); ImmutableList<String> reasons = builder.build(); if (reasons.isEmpty()) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Skipping {} as it is up-to-date.", context.getWork().getDisplayName()); } return new UpToDateResult() { @Override public ImmutableList<String> getOutOfDateReasons() { return ImmutableList.of(); } @Override public ImmutableSortedMap<String, FileCollectionFingerprint> getFinalOutputs() { return changes.getPreviousExecution().getOutputFileProperties(); } @Override public OriginMetadata getOriginMetadata() { return changes.getPreviousExecution().getOriginMetadata(); } @Override public ExecutionOutcome getOutcome() { return ExecutionOutcome.UP_TO_DATE; } @Nullable @Override public Throwable getFailure() { return null; } }; } else { return executeBecause(reasons, context); } }).orElseGet(() -> executeBecause(NO_HISTORY, context)); }
From source file:com.facebook.buck.android.JavaLibraryGraphEnhancer.java
public Result createBuildableForAndroidResources(BuildRuleResolver ruleResolver, boolean createBuildableIfEmptyDeps) { ImmutableSortedSet<BuildRule> originalDeps = originalBuildRuleParams.getDeps(); ImmutableList<HasAndroidResourceDeps> androidResourceDeps = UberRDotJavaUtil .getAndroidResourceDeps(originalDeps); if (androidResourceDeps.isEmpty() && !createBuildableIfEmptyDeps) { return new Result(originalBuildRuleParams, Optional.<DummyRDotJava>absent()); }// w ww . j a va 2s . c o m DummyRDotJava.Builder ruleBuilder = DummyRDotJava.newDummyRDotJavaBuildableBuilder(buildRuleBuilderParams) .setBuildTarget(dummyRDotJavaBuildTarget).setAndroidResourceDeps(androidResourceDeps); for (HasAndroidResourceDeps resourceDep : androidResourceDeps) { ruleBuilder.addDep(resourceDep.getBuildTarget()); } BuildRule dummyRDotJavaBuildRule = ruleResolver.buildAndAddToIndex(ruleBuilder); final DummyRDotJava dummyRDotJava = (DummyRDotJava) dummyRDotJavaBuildRule.getBuildable(); ImmutableSortedSet<BuildRule> totalDeps = ImmutableSortedSet.<BuildRule>naturalOrder().addAll(originalDeps) .add(dummyRDotJavaBuildRule).build(); BuildRuleParams newBuildRuleParams = new BuildRuleParams(originalBuildRuleParams.getBuildTarget(), totalDeps, originalBuildRuleParams.getVisibilityPatterns(), originalBuildRuleParams.getPathRelativizer(), originalBuildRuleParams.getRuleKeyBuilderFactory()); return new Result(newBuildRuleParams, Optional.of(dummyRDotJava)); }
From source file:org.cyclop.web.components.column.WidgetFactory.java
private Component createForCollection(Row row, CqlPartitionKeyValue cqlPartitionKeyValue, CqlExtendedColumnName column, String componentId) { ImmutableList<CqlColumnValue> content = extractor.extractCollection(row, column); Component comp;// www . ja v a 2s .co m if (content.isEmpty()) { comp = createForEmptyColumn(componentId); } else { comp = new CollectionViewPanel(componentId, cqlPartitionKeyValue, content); } return comp; }
From source file:com.google.api.tools.framework.aspects.authentication.AuthConfigAspect.java
@Override public String getDocumentationTitle(ProtoElement element) { ImmutableList<String> scopes = getOauthScopes(element); return scopes.isEmpty() ? null : "Authorization"; }