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.raml.utilities.format.Joiner.java

public String join(Iterable<?> stuff) {
    if (stuff == null || Iterables.isEmpty(stuff)) {
        // TODO: if ifEmpty is not specified default to prefix + suffix instead.
        return ifEmpty;
    }/*  ww w  .  jav  a  2s. c  o m*/

    StringBuilder builder = new StringBuilder(this.prefix);
    this.joiner.appendTo(builder, stuff);
    builder.append(suffix);
    return builder.toString();
}

From source file:de.cosmocode.commons.validation.TrueRule.java

@Override
public boolean none(Iterable<? extends Object> inputs) {
    Preconditions.checkNotNull(inputs, "Inputs");
    return Iterables.isEmpty(inputs);
}

From source file:com.palantir.atlasdb.jackson.TableRangeSerializer.java

@Override
public void serialize(TableRange value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonGenerationException {
    jgen.writeStartObject();// w ww.j ava 2  s.c o  m
    {
        jgen.writeStringField("table", value.getTableName());
        jgen.writeBinaryField("raw_start", value.getStartRow());
        jgen.writeBinaryField("raw_end", value.getEndRow());
        jgen.writeNumberField("batch_size", value.getBatchSize());
        if (!Iterables.isEmpty(value.getColumns())) {
            jgen.writeArrayFieldStart("cols");
            {
                for (byte[] column : value.getColumns()) {
                    jgen.writeString(PtBytes.toString(column));
                }
            }
            jgen.writeEndArray();
        }
    }
    jgen.writeEndObject();
}

From source file:org.apache.brooklyn.entity.group.FirstFromRemovalStrategy.java

@Nullable
@Override// w w w .  j a  v a 2s .  c o  m
public Entity apply(@Nullable Collection<Entity> input) {
    List<RemovalStrategy> strategies = config().get(STRATEGIES);
    if (strategies == null || Iterables.isEmpty(strategies)) {
        return null;
    }
    for (RemovalStrategy strategy : strategies) {
        Entity entity = strategy.apply(input);
        if (entity != null) {
            return entity;
        }
    }
    return null;
}

From source file:dagger2.internal.codegen.SourceFileGenerationException.java

private static String createMessage(Iterable<ClassName> generatedClassNames, String message) {
    return String.format("Could not generate %s: %s.",
            Iterables.isEmpty(generatedClassNames) ? "unknown files" : Iterables.toString(generatedClassNames),
            message);//  w  ww  .  ja v  a2 s .c o m
}

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

@Override
public String render(final GetDataPoliciesResult br) {
    final DataPolicyList dataPolicyList = br.getResult();
    if (null == dataPolicyList || dataPolicyList.getDataPolicies() == null
            || Iterables.isEmpty(dataPolicyList.getDataPolicies())) {
        return "No Data Policies returned.";
    }/*from  w  w  w  .  j  av a2  s. c  o  m*/
    this.dataPolicies = dataPolicyList.getDataPolicies();

    initTable(ImmutableList.of("Name", "Created", "Versioning", "Checksum Type", "End-to-End CRC Required",
            "Blobbing Enabled", "Default Blob Size", "Default Get Job Priority", "Default Put Job Priority",
            "Default Verify Job Priority", "Id", "LTFS Object Naming"));
    setTableDataAlignment(ImmutableList.of(ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_RIGHT,
            ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT,
            ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT,
            ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT));
    return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents());
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.query.ISequenceElementQuery.java

/**
 * Check the presence of the absolute bounds flag.
 * /* w w  w .  java2s  .  c o  m*/
 * @return true if the element is flagged.
 */
public boolean hasAbsoluteBoundsFlag() {
    if (event.getNotationView() != null && event.getNotationView().getElement() instanceof DDiagramElement) {
        DDiagramElement dde = (DDiagramElement) event.getNotationView().getElement();
        return !Iterables.isEmpty(Iterables.filter(dde.getGraphicalFilters(), AbsoluteBoundsFilter.class));
    }
    return false;
}

From source file:com.google.errorprone.bugpatterns.ObjectToString.java

private static boolean finalNoOverrides(Type type, VisitorState state) {
    if (type == null) {
        return false;
    }/*from  ww w . j a  va 2  s . c  o m*/
    // We don't flag use of toString() on non-final objects because sub classes might have a
    // meaningful toString() override.
    if (!type.isFinal()) {
        return false;
    }
    Types types = state.getTypes();
    Names names = Names.instance(state.context);
    // find Object.toString
    MethodSymbol toString = (MethodSymbol) state.getSymtab().objectType.tsym.members()
            .findFirst(names.toString);
    // We explore the superclasses of the receiver type as well as the interfaces it
    // implements and we collect all overrides of java.lang.Object.toString(). If one of those
    // overrides is present, then we don't flag it.
    return Iterables
            .isEmpty(types.membersClosure(type, /* skipInterface= */ false).getSymbolsByName(names.toString,
                    m -> m != toString && m.overrides(toString, type.tsym, types, /* checkResult= */ false)));
}

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

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    } else if (o instanceof ApiSerializationConfig) {
        ApiSerializationConfig config = (ApiSerializationConfig) o;
        return Iterables.isEmpty(getConfigurationInconsistencies(config));
    } else {/*from  w ww . j a v  a  2 s  .  c  o  m*/
        return false;
    }
}

From source file:com.palantir.atlasdb.table.description.IndexMetadata.java

public static IndexMetadata createIndex(String name, String javaName, Iterable<IndexComponent> rowComponents,
        CachePriority cachePriority, PartitionStrategy partitionStrategy, ConflictHandler conflictHandler,
        boolean rangeScanAllowed, int explicitCompressionBlockSizeKB, boolean negativeLookups,
        IndexCondition indexCondition, IndexType indexType, SweepStrategy sweepStrategy,
        ExpirationStrategy expirationStrategy, boolean appendHeavyAndReadLight) {
    Validate.isTrue(!Iterables.isEmpty(rowComponents));
    Iterable<IndexComponent> colComponents = ImmutableList.<IndexComponent>of();
    return new IndexMetadata(name, javaName, rowComponents, colComponents,
            getColNameToAccessFrom(rowComponents, colComponents, indexCondition), cachePriority,
            partitionStrategy, conflictHandler, rangeScanAllowed, explicitCompressionBlockSizeKB,
            negativeLookups, indexCondition, indexType, sweepStrategy, expirationStrategy,
            appendHeavyAndReadLight);//from   w  ww  . jav a2  s.  c om
}