Example usage for com.google.common.collect ImmutableList isEmpty

List of usage examples for com.google.common.collect ImmutableList isEmpty

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:org.waveprotocol.box.server.persistence.blocks.impl.SegmentOperationImpl.java

public SegmentOperationImpl(ImmutableList<? extends WaveletOperation> operations) {
    Preconditions.checkArgument(!operations.isEmpty(), "No operations");
    rawOperation = new RawOperation(GsonSerializer.OPERATION_SERIALIZER, operations,
            operations.get(operations.size() - 1).getContext());
}

From source file:com.facebook.buck.cxx.ArchiveStep.java

@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
    ImmutableList<String> allInputs = getAllInputs();
    if (allInputs.isEmpty()) {
        filesystem.writeContentsToPath("!<arch>\n", output);
        return StepExecutionResult.SUCCESS;
    } else {// w w w . j a  va  2 s  .c  om
        ImmutableList<String> archiveCommandPrefix = ImmutableList.<String>builder().addAll(archiverCommand)
                .addAll(archiverFlags).addAll(archiverExtraFlags).addAll(archiver.outputArgs(output.toString()))
                .build();
        CommandSplitter commandSplitter = new CommandSplitter(archiveCommandPrefix);
        for (ImmutableList<String> command : commandSplitter.getCommandsForArguments(allInputs)) {
            ProcessExecutor.Result result = runArchiver(context, command);
            if (result.getExitCode() != 0) {
                return StepExecutionResult.of(result);
            }
        }
        return StepExecutionResult.SUCCESS;
    }
}

From source file:com.google.shipshape.analyzers.JavacAnalyzer.java

@Override
public ImmutableList<Note> analyze(ShipshapeContext shipshapeContext, JavaCompilationDetails details)
        throws AnalyzerException {
    ImmutableList.Builder<Note> notes = new ImmutableList.Builder<>();

    if (details.getAnalysisCrash() != null) {
        throw new AnalyzerException(getCategory(), shipshapeContext, "Exception from javac",
                details.getAnalysisCrash());
    }/*  w  w w.  j  a v a 2  s  . c o m*/

    ImmutableList<CompilationUnitTree> asts = ImmutableList.copyOf(details.getAsts());

    if (asts.isEmpty()) {
        logger.info(
                "No ASTs found to process for compilation unit "
                        + details.getCompilationUnit().getVName().getSignature(),
                shipshapeContext, getCategory());
    }

    for (CompilationUnitTree file : asts) {
        URI uri = file.getSourceFile().toUri();
        String path = getPathRelativeToRoot(shipshapeContext, uri);
        logger.info("Investigating file " + path, shipshapeContext, getCategory());
        if (path == null) {
            String msg = String.format("The provided path %s was invalid for root %s", path,
                    shipshapeContext.getRepoRoot());
            throw new AnalyzerException(getCategory(), shipshapeContext, msg);
        }
        if (isRelevantJavaFile(shipshapeContext, path)) {
            logger.info("Analyzing file " + path, shipshapeContext, getCategory());
            notes.addAll(analyzeFile(shipshapeContext, details, file, path));
        }
    }
    return notes.build();
}

From source file:com.facebook.buck.event.listener.AbstractScribeEventListenerConfig.java

/**
 * @return Statuses that allow BuildRuleFinished events to be logged to Scribe. Will return a
 *     subset of https://fburl.com/m4o5p1mg
 *//*from  w ww  .jav  a  2  s.c o m*/
@Value.Lazy
public Iterable<String> getEnabledBuildRuleFinishedStatuses() {
    ImmutableList<String> list = getDelegate().getListWithoutComments(BUILDFILE_SECTION_NAME,
            "enabled_build_rule_finished_statuses");
    return list.isEmpty() ? ImmutableList.of("FAIL") : list;
}

From source file:org.summer.dsl.builder.impl.RegistryBuilderParticipant.java

public void build(IBuildContext buildContext, IProgressMonitor monitor) throws CoreException {
    ImmutableList<IXtextBuilderParticipant> participants = getParticipants();
    if (participants.isEmpty())
        return;/*from   w  w w.  ja  v a  2 s  . c  o  m*/
    SubMonitor progress = SubMonitor.convert(monitor, participants.size());
    progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants);
    for (IXtextBuilderParticipant participant : participants) {
        if (progress.isCanceled())
            throw new OperationCanceledException();
        participant.build(buildContext, progress.newChild(1));
    }
}

From source file:com.goodow.realtime.server.rpc.DeltaHandler.java

boolean fetchDeltas(JsonObject obj, ObjectId key, long version, Long endVersion)
        throws IOException, SlobNotFoundException, AccessDeniedException {
    SlobStore store = slobFacilities.getSlobStore();
    HistoryResult history = store.loadHistory(key, version, endVersion);
    ImmutableList<Delta<String>> data = history.getData();
    obj.add(Params.DELTAS, serializeDeltas(version, data));
    if (data.isEmpty()) {
        return true;
    }//from w w  w. j a  va  2 s  .c  o  m
    if (history.hasMore()) {
        obj.addProperty(Params.HAS_MORE, history.hasMore());
    }
    return false;
}

From source file:com.facebook.buck.features.zip.rules.ZipFileDescription.java

@Override
public Zip createBuildRule(BuildRuleCreationContextWithTargetGraph context, BuildTarget buildTarget,
        BuildRuleParams params, ZipFileDescriptionArg args) {

    ImmutableList<SourcePath> zipSources = args.getZipSrcs();
    Optional<Boolean> mergeSourceZips = args.getMergeSourceZips();

    if (!zipSources.isEmpty() && mergeSourceZips.isPresent())
        throw new IllegalArgumentException(
                "Illegal to define merge_source_zips when zip_srcs is present in " + buildTarget);

    return new Zip(new SourcePathRuleFinder(context.getActionGraphBuilder()), buildTarget,
            context.getProjectFilesystem(), args.getOut(), args.getSrcs(), zipSources, args.getFlatten(),
            mergeSourceZips, args.getEntriesToExclude());
}

From source file:org.apache.james.dlp.eventsourcing.aggregates.DLPDomainConfiguration.java

public List<Event> clear() {
    ImmutableList<DLPConfigurationItem> rules = retrieveRules().getItems();
    if (!rules.isEmpty()) {
        ImmutableList<Event> events = ImmutableList
                .of(new ConfigurationItemsRemoved(aggregateId, history.getNextEventId(), rules));
        events.forEach(this::apply);
        return events;
    } else {//from  w  w  w  .  j  a  va 2s  .  c o m
        return ImmutableList.of();
    }
}

From source file:com.google.devtools.build.skyframe.CycleDeduper.java

/**
 * Marks a non-empty list representing a cycle of unique values as being seen and returns true
 * iff the cycle hasn't been seen before, accounting for logical equivalence of cycles.
 *
 * For example, the cycle 'a' -> 'b' -> 'c' -> 'a' is represented by the list ['a', 'b', 'c']
 * and is logically equivalent to the cycle represented by the list ['b', 'c', 'a'].
 *//*from ww  w  . ja v a  2  s  .  c om*/
public boolean seen(ImmutableList<T> cycle) {
    ImmutableSet<T> cycleMembers = ImmutableSet.copyOf(cycle);
    Preconditions.checkState(!cycle.isEmpty());
    Preconditions.checkState(cycle.size() == cycleMembers.size(),
            "cycle doesn't have unique members: " + cycle);

    if (knownCyclesByMembers.containsEntry(cycleMembers, cycle)) {
        return false;
    }

    // Of the C cycles, suppose there are D cycles that have the same members (but are in an
    // incompatible order). This code path takes O(D * L) time. The common case is that D is
    // very small.
    boolean found = false;
    for (ImmutableList<T> candidateCycle : knownCyclesByMembers.get(cycleMembers)) {
        int startPos = candidateCycle.indexOf(cycle.get(0));
        // The use of a multimap keyed by cycle members guarantees that the first element of 'cycle'
        // is present in 'candidateCycle'.
        Preconditions.checkState(startPos >= 0);
        if (equalsWithSingleLoopFrom(cycle, candidateCycle, startPos)) {
            found = true;
            break;
        }
    }
    // We add the cycle even if it's a duplicate so that future exact copies of this can be
    // processed in O(L) time. We are already using O(CL) memory, and this optimization doesn't
    // change that.
    knownCyclesByMembers.put(cycleMembers, cycle);
    return !found;
}

From source file:com.facebook.buck.util.network.AbstractBatchingLogger.java

private ListenableFuture<Void> sendBatch() {
    ImmutableList<BatchEntry> toSend = batch.build();
    batch = ImmutableList.builder();/*from   w  w w.  ja v  a 2  s  . c  o  m*/
    currentBatchSize = 0;
    if (toSend.isEmpty()) {
        return Futures.immediateFuture(null);
    } else {
        return logMultiple(toSend);
    }
}