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:com.publictransitanalytics.scoregenerator.walking.ForwardTimeTracker.java

@Override
public boolean shouldReplace(final MovementPath currentPath, final LocalDateTime otherTime) {
    final ImmutableList<Movement> movements = currentPath.getMovements();
    if (movements.isEmpty()) {
        return false;
    }// w ww . ja  v  a  2 s  .  com

    final Movement terminal = movements.get(movements.size() - 1);
    return otherTime.isBefore(terminal.getEndTime());
}

From source file:com.publictransitanalytics.scoregenerator.walking.BackwardTimeTracker.java

@Override
public boolean shouldReplace(final MovementPath currentPath, final LocalDateTime otherTime) {
    final ImmutableList<Movement> movements = currentPath.getMovements();
    if (movements.isEmpty()) {
        return false;
    }//from  www  .  j a v  a 2  s.c  om

    final Movement terminal = movements.get(0);
    return otherTime.isAfter(terminal.getStartTime());
}

From source file:google.registry.tools.ListCreditsCommand.java

@Override
public void run() {
    for (Registrar registrar : Registrar.loadAll()) {
        ImmutableList<String> creditStrings = createCreditStrings(registrar);
        if (!creditStrings.isEmpty()) {
            System.out.println(registrar.getClientId());
            System.out.print(Joiner.on("").join(creditStrings));
            System.out.println();
        }//from   ww  w  .  jav  a2s . c o  m
    }
}

From source file:org.ambraproject.rhino.content.xml.AssetNodesByDoi.java

/**
 * Get the XML nodes associated with a DOI. Typically the returned list will contain exactly one node. It is valid
 * (but rare) for an article XML document to contain multiple asset nodes with the same DOI, in which case the
 * returned list contains them in their order from the original document.
 *
 * @param doi an asset DOI//from  ww  w .  j a va 2  s .  c o m
 * @return a non-empty list
 * @throws IllegalArgumentException if there is no asset matching the DOI (equivalently, if {@code
 *                                  !this.getDois().contains(doi)})
 * @throws NullPointerException     if {@code doi == null}
 */
public ImmutableList<Node> getNodes(Doi doi) {
    Preconditions.checkNotNull(doi);
    ImmutableList<Node> nodes = nodeMap.get(doi);
    if (nodes.isEmpty()) {
        throw new IllegalArgumentException("DOI not matched to asset node: " + doi);
    }
    return nodes;
}

From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.types.DeleteMemberAction.java

@Override
public void actionPerformed(ActionEvent event) {
    final ImmutableList<TypeMember> members = typeEditor.getSelectedMembers();
    if (members.isEmpty() || CMessageBox.showYesNoQuestion(owner,
            "Do you really want to delete these member(s)?") != JOptionPane.YES_OPTION) {
        return;//from   w w w  .  j av a2  s  .  c  om
    }

    try {
        for (final TypeMember member : members) {
            typeManager.deleteMember(member);
        }
    } catch (CouldntDeleteException | CouldntSaveDataException exception) {
        CUtilityFunctions.logException(exception);
    }
}

From source file:com.android.build.gradle.internal.pipeline.FilterableStreamCollection.java

@NonNull
public Map<File, Format> getPipelineOutput(@NonNull StreamFilter streamFilter) {
    ImmutableList<TransformStream> streams = getStreams(streamFilter);
    if (streams.isEmpty()) {
        return ImmutableMap.of();
    }/*from  w w  w .  j  a va  2 s .  c  o m*/

    ImmutableMap.Builder<File, Format> builder = ImmutableMap.builder();
    for (TransformStream stream : streams) {
        // get the input for it
        TransformInput input = stream.asNonIncrementalInput();

        for (JarInput jarInput : input.getJarInputs()) {
            builder.put(jarInput.getFile(), Format.JAR);
        }
        for (DirectoryInput directoryInput : input.getDirectoryInputs()) {
            builder.put(directoryInput.getFile(), Format.DIRECTORY);
        }
    }

    return builder.build();
}

From source file:com.facebook.buck.features.python.toolchain.impl.PythonInterpreterFromConfig.java

private Path findInterpreter(ImmutableList<String> interpreterNames) {
    Preconditions.checkArgument(!interpreterNames.isEmpty());
    for (String interpreterName : interpreterNames) {
        Optional<Path> python = executableFinder.getOptionalExecutable(Paths.get(interpreterName),
                pythonBuckConfig.getDelegate().getEnvironment());
        if (python.isPresent()) {
            return python.get().toAbsolutePath();
        }/*  w w  w  .  j a va2s .  c o  m*/
    }
    throw new HumanReadableException("No python interpreter found (searched %s).",
            Joiner.on(", ").join(interpreterNames));
}

From source file:com.facebook.buck.rules.macros.QueryOutputsMacroExpander.java

@Override
public ImmutableList<BuildRule> extractBuildTimeDeps(BuildTarget target, CellPathResolver cellNames,
        final BuildRuleResolver resolver, ImmutableList<String> input) throws MacroException {
    if (input.isEmpty()) {
        throw new MacroException("One quoted query expression is expected with optional flags");
    }// w  w w. ja  va  2 s.  c  o m
    String queryExpression = CharMatcher.anyOf("\"'").trimFrom(input.get(0));
    return ImmutableList.copyOf(resolveQuery(target, cellNames, resolver, queryExpression).map(queryTarget -> {
        Preconditions.checkState(queryTarget instanceof QueryBuildTarget);
        return resolver.getRule(((QueryBuildTarget) queryTarget).getBuildTarget());
    }).sorted().collect(Collectors.toList()));
}

From source file:com.facebook.buck.rules.macros.QueryOutputsMacroExpander.java

@Override
public String expand(BuildTarget target, CellPathResolver cellNames, BuildRuleResolver resolver,
        ImmutableList<String> input) throws MacroException {
    if (input.isEmpty()) {
        throw new MacroException("One quoted query expression is expected");
    }/*from w  w  w.j  av a2  s  .  c o  m*/
    String queryExpression = CharMatcher.anyOf("\"'").trimFrom(input.get(0));
    return resolveQuery(target, cellNames, resolver, queryExpression).map(queryTarget -> {
        Preconditions.checkState(queryTarget instanceof QueryBuildTarget);
        return resolver.getRule(((QueryBuildTarget) queryTarget).getBuildTarget());
    }).map(rule -> rule.getProjectFilesystem().resolve(rule.getPathToOutput())).filter(Objects::nonNull)
            .map(Path::toString).sorted().collect(Collectors.joining(" "));
}

From source file:com.facebook.buck.parser.ParserPythonInterpreterProvider.java

private Path findInterpreter(ImmutableList<String> interpreterNames) {
    Preconditions.checkArgument(!interpreterNames.isEmpty());
    for (String interpreterName : interpreterNames) {
        Optional<Path> python = executableFinder.getOptionalExecutable(Paths.get(interpreterName),
                parserConfig.getDelegate().getEnvironment());
        if (python.isPresent()) {
            return python.get().toAbsolutePath();
        }//w  ww  .j av a  2s. c  o m
    }
    throw new HumanReadableException("No python interpreter found (searched %s).",
            Joiner.on(", ").join(interpreterNames));
}