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.spectralogic.ds3cli.views.cli.GetBucketView.java

@Override
public String render(final GetBucketResult br) {
    // Bucket details
    final String bucketDesc = new com.spectralogic.ds3cli.views.cli.GetBucketDetailsView().render(br);

    if (null == br.getResult() || Iterables.isEmpty(br.getResult())) {
        return "No objects were reported in bucket.";
    }/*from w  ww  . j  a  v  a 2s .c o  m*/
    this.contents = br.getResult();
    initTable(ImmutableList.of("File Name", "Size", "Owner", "Last Modified", "ETag"));
    setTableDataAlignment(ImmutableList.of(ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_RIGHT,
            ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_RIGHT));

    final String bucketContents = ASCIITable.getInstance().getTable(getHeaders(), formatTableContents());

    return String.format("%s\n%s", bucketDesc, bucketContents);
}

From source file:com.spectralogic.ds3cli.views.cli.GetObjectsOnTapeView.java

@Override
public String render(final GetObjectsOnTapeResult blobsResult) {
    final Iterable<BulkObject> bulkObjects = blobsResult.getResult();
    if (null == bulkObjects || Iterables.isEmpty(bulkObjects)) {
        return "No objects were reported in tape '" + blobsResult.getTapeId() + "'";
    }/*  w w  w  . j  a  va  2 s  .  c  om*/
    this.objectIterable = bulkObjects;

    initTable(ImmutableList.of("Name", "Bucket", "Size", "Id"));
    setTableDataAlignment(ImmutableList.of(ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_RIGHT,
            ASCIITable.ALIGN_RIGHT));
    return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents());
}

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

@Override
public Iterable<T> extract(Context<K, W> c) throws IOException {
    Iterable<T> result = c.readBuffers(bufferTag, c.sourceWindows());
    return Iterables.isEmpty(result) ? null : result;
}

From source file:com.spectralogic.ds3cli.views.cli.GetPoolsView.java

@Override
public String render(final GetPoolsResult poolsResult) {
    if (null == poolsResult.getResult().getPools() || Iterables.isEmpty(poolsResult.getResult().getPools())) {
        return "No Pools returned.";
    }//  w  w w .  j a v  a 2s .c o m

    this.poolIterator = poolsResult.getResult().getPools();

    initTable(ImmutableList.of("Pool", "ID", "Type", "Capacity", "Bucket Id", "Partition Id",
            "Assigned to Storage Domain", "Last Modified", "Last Verification"));
    return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents());
}

From source file:see.util.Reduce.java

/**
 * Fold a sequence without an initial value.
 *
 * @param values sequence to fold/* www  . jav a2  s .c  o  m*/
 * @param func reducing function
 * @param <T> input and result type
 * @return reduce result
 */
public static <T> T reduce(Iterable<? extends T> values, FoldFunction<? super T, T> func) {
    Preconditions.checkArgument(!Iterables.isEmpty(values), "Cannot reduce empty list");

    return fold(Iterables.getFirst(values, null), Iterables.skip(values, 1), func);
}

From source file:eu.trentorise.opendata.semtext.SemTexts.java

/**
 * Determines the best meaning among the given ones according to their
 * probabilities. If no best meaning is found null is returned.
 *
 * @param meanings a sorted list of meanings, with the first ones being the
 * most important.//  w  w  w  .j ava2  s.  c o m
 * @return the disambiguated meaning or null if no meaning can be clearly
 * identified.
 */
@Nullable
public static Meaning disambiguate(Iterable<Meaning> meanings) {

    if (Iterables.isEmpty(meanings)) {
        return null;
    }

    int size = Iterables.size(meanings);

    if (size == 1) {
        Meaning m = meanings.iterator().next();
        if (m.getId() == null) {
            return null;
        } else {
            return m;
        }
    }

    Meaning first = Iterables.getFirst(meanings, null);

    if (first.getProbability() > DISAMBIGUATION_FACTOR / size && first.getId() != null) {
        return first;
    } else {
        return null;
    }

}

From source file:com.google.api.server.spi.config.model.ApiAuthConfig.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    } else if (o instanceof ApiAuthConfig) {
        ApiAuthConfig config = (ApiAuthConfig) o;
        return Iterables.isEmpty(getConfigurationInconsistencies(config));
    } else {/*from  ww  w  .ja va  2s  .  com*/
        return false;
    }
}

From source file:org.sonar.java.checks.xml.web.SecurityConstraintsInWebXmlCheck.java

private boolean hasNoSecurityConstraint(XmlCheckContext context) {
    return Iterables.isEmpty(context.evaluateOnDocument(securityConstraintExpression));
}

From source file:com.spectralogic.ds3cli.views.cli.SuspectedObjectsView.java

@Override
public String render(final SuspectedObjectResult obj) {
    final ImmutableList<BulkObject> bulkObjects = obj.getResult();
    if (bulkObjects == null || Iterables.isEmpty(bulkObjects)) {
        return "No suspected blobs returned";
    }//from  w  w  w.ja v  a 2s.c o m

    suspectBlobTapes = bulkObjects;
    initTable(ImmutableList.of("Name", "Bucket", "In Cache", "Offset", "Length"));

    return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents());
}

From source file:com.reprezen.swagedit.editor.outline.OutlineContentProvider.java

@Override
public Object[] getElements(Object inputElement) {
    if (models == null || Iterables.isEmpty(models)) {
        return null;
    }/*from  ww  w . j  a v a  2  s .  c om*/

    List<Object> roots = Lists.newArrayList();
    for (Model model : models) {
        roots.add(model.getRoot());
    }

    return roots.toArray(new Object[roots.size()]);
}