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:org.chaston.oakfunds.storage.mgmt.SchemaDeploymentTask.java

@Inject
SchemaDeploymentTask(SchemaUpdater schemaUpdater) throws SQLException {
    Iterable<SchemaDiscrepancy> remainingDiscrepancies = schemaUpdater.updateSchema();
    assert Iterables.isEmpty(remainingDiscrepancies);
}

From source file:org.gradle.api.internal.file.collections.ImmutableFileCollection.java

public static ImmutableFileCollection of(Iterable<File> files) {
    if (Iterables.isEmpty(files)) {
        return EMPTY;
    }//from  w  w  w .  j a v  a2  s . co  m
    return new FileOnlyImmutableFileCollection(ImmutableSet.copyOf(files));
}

From source file:org.trancecode.xproc.step.PipelineStepProcessor.java

private static Step addImplicitOutputPort(final Step pipeline) {
    if (Iterables.isEmpty(pipeline.getOutputPorts())) {
        return pipeline
                .declarePort(Port.newOutputPort(pipeline.getName(), XProcPorts.RESULT, pipeline.getLocation()));
    }//from  w ww . ja  va 2  s  .com

    return pipeline;
}

From source file:com.google.errorprone.ErrorPronePlugins.java

public static ScannerSupplier loadPlugins(ScannerSupplier scannerSupplier, Context context) {

    JavaFileManager fileManager = context.get(JavaFileManager.class);
    // Search ANNOTATION_PROCESSOR_PATH if it's available. Unlike in annotation processor
    // discovery, we never search CLASS_PATH.
    if (!fileManager.hasLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH)) {
        return scannerSupplier;
    }/*  ww  w .  ja  v a  2 s .  c  o  m*/
    ClassLoader loader = fileManager.getClassLoader(StandardLocation.ANNOTATION_PROCESSOR_PATH);
    Iterable<BugChecker> extraBugCheckers = ServiceLoader.load(BugChecker.class, loader);
    if (Iterables.isEmpty(extraBugCheckers)) {
        return scannerSupplier;
    }
    return scannerSupplier
            .plus(ScannerSupplier.fromBugCheckerClasses(Iterables.transform(extraBugCheckers, GET_CLASS)));
}

From source file:org.apache.metron.statistics.sampling.SamplerUtil.java

public Sampler merge(Iterable<Sampler> samplers, Optional<Sampler> baseSampler) {
    if (Iterables.isEmpty(samplers)) {
        return null;
    }//from  w w w .j  ava2s.c  om
    Sampler ret = baseSampler.orElse(Iterables.getFirst(samplers, null).cloneEmpty());
    for (Sampler s : samplers) {
        ret.addAll(s.get());
    }
    return ret;
}

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

/**
 * Construct a target completion event for a failed target, with the given non-empty root causes.
 *//*from  w w w . j  a  va2s. c om*/
public static AspectCompleteEvent createFailed(AspectValue value, NestedSet<Cause> rootCauses) {
    Preconditions.checkArgument(!Iterables.isEmpty(rootCauses));
    return new AspectCompleteEvent(value, rootCauses);
}

From source file:org.eclipse.xtext.resource.impl.AbstractCompoundSelectable.java

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

From source file:ch.acanda.eclipse.pmd.builder.ViolationProcessor.java

public void annotate(final IFile file, final Iterable<RuleViolation> violations)
        throws CoreException, IOException {
    MarkerUtil.removeAllMarkers(file);/*from  w ww .  j a  va  2s  .c om*/
    if (!Iterables.isEmpty(violations)) {
        final String content = Files.toString(file.getRawLocation().toFile(),
                Charset.forName(file.getCharset()));
        for (final RuleViolation violation : violations) {
            MarkerUtil.addMarker(file, content, violation);
        }
    }
}

From source file:com.google.cloud.dataflow.sdk.testing.StaticWindows.java

public static <W extends BoundedWindow> StaticWindows of(Coder<W> coder, Iterable<W> windows) {
    checkArgument(!Iterables.isEmpty(windows), "Input windows to StaticWindows may not be empty");
    @SuppressWarnings("unchecked")
    StaticWindows windowFn = new StaticWindows(
            WindowSupplier.of((Coder<BoundedWindow>) coder, (Iterable<BoundedWindow>) windows),
            (Coder<BoundedWindow>) coder, false);
    return windowFn;
}

From source file:org.apache.cassandra.db.commitlog.ReplayPosition.java

/**
 * Convenience method to compute the replay position for a group of SSTables.
 * @param sstables//w  w  w . j  a  v  a  2  s  .  co  m
 * @return the most recent (highest) replay position
 */
public static ReplayPosition getReplayPosition(Iterable<? extends SSTable> sstables) {
    if (Iterables.isEmpty(sstables))
        return NONE;

    Function<SSTable, ReplayPosition> f = new Function<SSTable, ReplayPosition>() {
        public ReplayPosition apply(SSTable sstable) {
            return sstable.replayPosition;
        }
    };
    Ordering<ReplayPosition> ordering = Ordering.from(ReplayPosition.comparator);
    return ordering.max(Iterables.transform(sstables, f));
}