Example usage for com.google.common.base Joiner skipNulls

List of usage examples for com.google.common.base Joiner skipNulls

Introduction

In this page you can find the example usage for com.google.common.base Joiner skipNulls.

Prototype

@CheckReturnValue
public Joiner skipNulls() 

Source Link

Document

Returns a joiner with the same behavior as this joiner, except automatically skipping over any provided null elements.

Usage

From source file:google.registry.tmch.LordnTask.java

/** Returns the corresponding CSV LORDN line for a sunrise domain. */
public static String getCsvLineForSunriseDomain(DomainResource domain, DateTime transactionTime) {
    // Only skip nulls in the outer join because only application time is allowed to be null.
    Joiner joiner = Joiner.on(',');
    return joiner.skipNulls()
            .join(joiner.join(domain.getRepoId(), domain.getFullyQualifiedDomainName(), domain.getSmdId(),
                    getIanaIdentifier(domain.getCreationClientId()), transactionTime), // Used as creation time.
                    domain.getApplicationTime()); // This may be null for sunrise QLP domains.
}

From source file:google.registry.tmch.LordnTask.java

/** Returns the corresponding CSV LORDN line for a claims domain. */
public static String getCsvLineForClaimsDomain(DomainResource domain, DateTime transactionTime) {
    // Only skip nulls in the outer join because only application time is allowed to be null.
    Joiner joiner = Joiner.on(',');
    return joiner.skipNulls()
            .join(joiner.join(domain.getRepoId(), domain.getFullyQualifiedDomainName(),
                    domain.getLaunchNotice().getNoticeId().getTcnId(),
                    getIanaIdentifier(domain.getCreationClientId()), transactionTime, // Used as creation time.
                    domain.getLaunchNotice().getAcceptedTime()), domain.getApplicationTime()); // This may be null if this wasn't from landrush.
}

From source file:org.apache.solr.update.MergeIndexesCommand.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder(super.toString());
    Joiner joiner = Joiner.on(",");
    Iterable<String> directories = Iterables.transform(readers, new Function<DirectoryReader, String>() {
        public String apply(DirectoryReader reader) {
            return reader.directory().toString();
        }/* w  w  w. j av  a  2 s  .  c om*/
    });
    joiner.skipNulls().join(sb, directories);
    sb.append('}');
    return sb.toString();
}

From source file:appeng.services.export.MinecraftItemCSVExporter.java

@Override
public void export() {
    final Iterable<Item> items = this.itemRegistry.typeSafeIterable();
    final List<Item> itemList = Lists.newArrayList(items);

    final List<String> lines = Lists.transform(itemList,
            new ItemRowExtractFunction(this.itemRegistry, this.mode));

    final Joiner newLineJoiner = Joiner.on('\n');
    final Joiner newLineJoinerIgnoringNull = newLineJoiner.skipNulls();
    final String joined = newLineJoinerIgnoringNull.join(lines);

    final File file = new File(this.exportDirectory, ITEM_CSV_FILE_NAME);

    try {//from  w w  w  .j av  a 2s.c  o m
        FileUtils.forceMkdir(this.exportDirectory);

        final Writer writer = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8")));

        final String header = this.mode == ExportMode.MINIMAL ? MINIMAL_HEADER : VERBOSE_HEADER;
        writer.write(header);
        writer.write("\n");
        writer.write(joined);
        writer.flush();
        writer.close();

        AELog.info(EXPORT_SUCCESSFUL_MESSAGE, lines.size(), ITEM_CSV_FILE_NAME);
    } catch (final IOException e) {
        AELog.warn(EXPORT_UNSUCCESSFUL_MESSAGE);
        AELog.debug(e);
    }
}