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

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

Introduction

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

Prototype

public static boolean isEmpty(Iterable<?> iterable) 

Source Link

Document

Determines if the given iterable contains no elements.

Usage

From source file:com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction.java

/**
 * Creates a new instance./*from   ww w .  j ava2  s . co m*/
 *
 * @param owner the action owner
 * @param inputs the list of TreeArtifacts that must be resolved and expanded before evaluating
 *     the contents of {@link commandLine}.
 * @param output the Artifact that will be created by executing this Action
 * @param commandLine the contents to be written to the file
 * @param type the type of the file
 * @param charset the charset of the file
 */
public ParameterFileWriteAction(ActionOwner owner, Iterable<Artifact> inputs, Artifact output,
        CommandLine commandLine, ParameterFileType type, Charset charset) {
    super(owner, ImmutableList.copyOf(inputs), output, false);
    this.commandLine = commandLine;
    this.type = type;
    this.charset = charset;
    this.hasInputArtifactToExpand = !Iterables.isEmpty(inputs);
}

From source file:eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetContentProvider.java

@Override
public boolean hasChildren(Object element) {
    if (element instanceof SchemaCategory) {
        return !Iterables.isEmpty(((SchemaCategory) element).getSchemas());
    }/*from  ww w  .j a  v  a  2 s  .  com*/
    return false;
}

From source file:com.ebuddy.cassandra.structure.DefaultPath.java

@Override
public boolean isEmpty() {
    return Iterables.isEmpty(pathElements);
}

From source file:org.immutables.generator.Intrinsics.java

public static boolean $if(Object value) {
    if (value == null) {
        return false;
    }/*  ww w  .jav  a 2 s  .  c  o  m*/
    if (value instanceof Boolean) {
        return ((Boolean) value).booleanValue();
    }
    if (value instanceof String) {
        return !((String) value).isEmpty();
    }
    if (value instanceof Iterable<?>) {
        return !Iterables.isEmpty((Iterable<?>) value);
    }
    if (value instanceof Number) {
        return ((Number) value).intValue() != 0;
    }
    if (value instanceof Optional<?>) {
        return ((Optional<?>) value).isPresent();
    }
    return true;
}

From source file:com.google.cloud.dataflow.sdk.util.CombiningOutputBuffer.java

@Override
public OutputT extract(OutputBuffer.Context<K, W> c) throws IOException {
    Iterable<AccumT> accums = FluentIterable.from(c.sourceWindows())
            .transform(Functions.forMap(inMemoryBuffer, null)).filter(Predicates.notNull())
            .append(c.readBuffers(accumTag, c.sourceWindows()));

    AccumT result = Iterables.isEmpty(accums) ? null : combineFn.mergeAccumulators(c.key(), accums);

    clear(c);/*from   w  ww .  jav  a 2s  .  c  om*/
    inMemoryBuffer.put(c.window(), result);

    return result == null ? null : combineFn.extractOutput(c.key(), result);
}

From source file:com.facebook.buck.features.go.GoCompileStep.java

@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    ArrayList<String> pathStrings = new ArrayList<>();
    for (Path path : srcs) {
        pathStrings.add(path.toString());
    }// w  w w  .jav a  2  s .com
    if (pathStrings.size() > 0) {
        ImmutableList.Builder<String> commandBuilder = ImmutableList.<String>builder()
                .addAll(compilerCommandPrefix).add("-p", packageName.toString()).add("-pack")
                .add("-trimpath", workingDirectory.toString()).add("-nolocalimports").addAll(flags)
                .add("-o", output.toString());

        if (asmSymabisPath.isPresent() && !Iterables.isEmpty(asmSrcs)) {
            commandBuilder.add("-symabis", asmSymabisPath.get().toString());
        }

        for (Path dir : includeDirectories) {
            commandBuilder.add("-I", dir.toString());
        }

        for (Map.Entry<Path, Path> entry : importPathMap.entrySet()) {
            commandBuilder.add("-importmap", entry.getKey() + "=" + entry.getValue());
        }

        if (asmHeaderPath.isPresent()) {
            commandBuilder.add("-asmhdr", asmHeaderPath.get().toString());
        }

        if (!allowExternalReferences) {
            // -complete means the package does not use any non Go code, so external functions
            // (e.g. Cgo, asm) aren't allowed.
            commandBuilder.add("-complete");
        }

        commandBuilder.addAll(pathStrings);

        return commandBuilder.build();
    } else {
        LOG.warn("No source files found in " + workingDirectory);
        return ImmutableList.of();
    }
}

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

@Override
public boolean isCycle(SkyKey key) throws InterruptedException {
    NodeEntry entry = getEntryForValue(key);
    if (entry == null) {
        return false;
    }// www  .  j av a 2s  .  c  o m
    ErrorInfo errorInfo = entry.getErrorInfo();
    return errorInfo != null && !Iterables.isEmpty(errorInfo.getCycleInfo());
}

From source file:cz.afri.smg.objects.sll.SMGSingleLinkedListConcretisation.java

@SuppressFBWarnings(value = "WMI_WRONG_MAP_ITERATOR", justification = "We need to iterate over keys here")
@Override//from w  ww . j  av  a 2s . co  m
public final Set<ReadableSMG> execute(final ReadableSMG pSMG) {
    Set<ReadableSMG> resultSet = new HashSet<>();

    WritableSMG newSMG = SMGFactory.createWritableCopy(pSMG);

    // Create new concrete object
    SMGRegion region = new SMGRegion(sll.getSize(), sll.getLabel() + "_element");
    newSMG.addHeapObject(region);

    // Replace all edges pointing to SLL with ones pointing to new region
    Map<SMGEdgePointsTo, SMGEdgePointsTo> toReplace = new HashMap<>();
    for (SMGEdgePointsTo pt : newSMG.getPTEdges()) {
        if (pt.getObject().equals(sll)) {
            SMGEdgePointsTo newPt = new SMGEdgePointsTo(pt.getValue(), region, sll.getOffset());
            toReplace.put(pt, newPt);
        }
    }

    for (SMGEdgePointsTo pt : toReplace.keySet()) {
        newSMG.removePointsToEdge(pt.getValue());
        newSMG.addPointsToEdge(toReplace.get(pt));
    }

    // Create new connection between new region and SLL
    Integer newValue = SMGValueFactory.getNewValue();
    newSMG.addValue(newValue);
    SMGEdgeHasValue newValueHv = new SMGEdgeHasValue(new CPointerType(), sll.getOffset(), region, newValue);
    newSMG.addHasValueEdge(newValueHv);
    SMGEdgePointsTo newValuePt = new SMGEdgePointsTo(newValue, sll, sll.getOffset());
    newSMG.addPointsToEdge(newValuePt);

    if (sll.getLength() > 0) {
        // Shorten SLL
        sll.addLength(-1);
    } else {
        // For SLL of length 0+, there is a case, when it had length 0 and can be
        // removed though
        WritableSMG newSMGWithoutSll = SMGFactory.createWritableCopy(pSMG);

        Integer value;
        if (Iterables.isEmpty(newSMGWithoutSll.getHVEdges(SMGEdgeHasValueFilter.objectFilter(sll)
                .filterAtOffset(sll.getOffset()).filterByType(CPointerType.getVoidPointer())))) {
            // Create new value
            value = SMGValueFactory.getNewValue();
            newSMGWithoutSll.addValue(value);
        } else {
            // Get outbound edge at binding offset (next pointer of last list item)
            value = newSMGWithoutSll.getUniqueHV(SMGEdgeHasValueFilter.objectFilter(sll)
                    .filterAtOffset(sll.getOffset()).filterByType(CPointerType.getVoidPointer()), false)
                    .getValue();
        }

        for (SMGEdgePointsTo pt : newSMGWithoutSll.getPTEdges()) {
            if (pt.getObject().equals(sll)) {
                SMGEdgeHasValueFilter filter = new SMGEdgeHasValueFilter().filterHavingValue(pt.getValue());
                SMGEdgeHasValue oldHv = newSMGWithoutSll.getUniqueHV(filter, false);
                SMGEdgeHasValue newHv = new SMGEdgeHasValue(CPointerType.getVoidPointer(), sll.getOffset(),
                        oldHv.getObject(), value);
                newSMGWithoutSll.addHasValueEdge(newHv);
                newSMGWithoutSll.removeHasValueEdge(oldHv);
                newSMGWithoutSll.removePointsToEdge(oldHv.getValue());
                newSMGWithoutSll.removeValue(oldHv.getValue());
            }
        }

        // Remove SLL and all appropriate edges
        SMGEdgeHasValueFilter filter = SMGEdgeHasValueFilter.objectFilter(sll);
        Set<SMGEdgeHasValue> toRemove = Sets.newHashSet(newSMGWithoutSll.getHVEdges(filter));
        for (SMGEdgeHasValue hv : toRemove) {
            newSMGWithoutSll.removeHasValueEdge(hv);
        }
        newSMGWithoutSll.removeHeapObject(sll);

        resultSet.add(newSMGWithoutSll);
    }

    resultSet.add(newSMG);

    return resultSet;
}

From source file:com.webbfontaine.valuewebb.irms.impl.risk.data.RiskResultCollector.java

private Optional<RiskColor> getHighestColor() {
    Set<RiskColor> colors = riskColorsFromResults(results);
    if (Iterables.isEmpty(colors)) {
        return Optional.absent();
    }/*w w  w  . jav a  2s.c o m*/

    return Optional.of(colorOrdering.greatestOf(colors, 1).get(0));
}

From source file:com.eucalyptus.cloudformation.config.CloudFormationServiceBuilder.java

@SuppressWarnings("unchecked")
private boolean noOtherEnabled(final ServiceConfiguration config) {
    return Iterables.isEmpty(ServiceConfigurations.filter(CloudFormation.class,
            Predicates.and(ServiceConfigurations.filterHostLocal(), ServiceConfigurations.filterEnabled(),
                    Predicates.not(Predicates.equalTo(config)))));
}