Example usage for com.google.common.base Strings emptyToNull

List of usage examples for com.google.common.base Strings emptyToNull

Introduction

In this page you can find the example usage for com.google.common.base Strings emptyToNull.

Prototype

@Nullable
public static String emptyToNull(@Nullable String string) 

Source Link

Document

Returns the given string if it is nonempty; null otherwise.

Usage

From source file:org.envirocar.server.core.entities.DimensionedNumber.java

/**
 * Creates a new {@code DimensionedNumber} for the specified value and unit.
 *
 * @param value the value//  www . ja  v  a2  s  .c  o m
 * @param unit  the unit
 */
public DimensionedNumber(BigDecimal value, String unit) {
    this.value = Preconditions.checkNotNull(value);
    this.unit = Preconditions.checkNotNull(Strings.emptyToNull(unit));
}

From source file:de.bund.bfr.knime.ui.StringTextField.java

@Override
protected void textChanged() {
    value = Strings.emptyToNull(getText().trim());
    valueValid = value != null || isOptional();
    super.textChanged();
}

From source file:io.druid.query.filter.StringValueMatcherColumnSelectorStrategy.java

@Override
public ValueMatcher makeValueMatcher(final DimensionSelector selector, String value) {
    value = Strings.emptyToNull(value);
    if (selector.getValueCardinality() == 0) {
        return BooleanValueMatcher.of(value == null);
    } else {//from  w  w  w.  ja  v  a 2 s.c  om
        return selector.makeValueMatcher(value);
    }
}

From source file:org.n52.shetland.ogc.ows.OwsAddress.java

public OwsAddress(List<String> deliveryPoint, String city, String administrativeArea, String postalCode,
        String country, List<String> electronicMailAddress) {
    this.deliveryPoint = deliveryPoint == null ? Collections.emptyList() : deliveryPoint;
    this.city = Optional.ofNullable(Strings.emptyToNull(city));
    this.administrativeArea = Optional.ofNullable(Strings.emptyToNull(administrativeArea));
    this.postalCode = Optional.ofNullable(Strings.emptyToNull(postalCode));
    this.country = Optional.ofNullable(Strings.emptyToNull(country));
    this.electronicMailAddress = electronicMailAddress == null ? Collections.emptyList()
            : electronicMailAddress;//from   w w w  .ja  v a2 s  .  co m
}

From source file:com.google.gerrit.server.change.CommentInfo.java

CommentInfo(PatchLineComment c, AccountInfo.Loader accountLoader) {
    id = Url.encode(c.getKey().get());/* www  .j a va 2  s . co m*/
    path = c.getKey().getParentKey().getFileName();
    if (c.getSide() == 0) {
        side = Side.PARENT;
    }
    if (c.getLine() > 0) {
        line = c.getLine();
    }
    inReplyTo = Url.encode(c.getParentUuid());
    message = Strings.emptyToNull(c.getMessage());
    updated = c.getWrittenOn();
    if (accountLoader != null) {
        author = accountLoader.get(c.getAuthor());
    }
}

From source file:org.n52.shetland.w3c.xlink.Link.java

public Link(URI href, URI role, URI arcrole, String title, Show show, Actuate actuate) {
    this.href = Optional.ofNullable(href);
    this.role = Optional.ofNullable(role);
    this.arcrole = Optional.ofNullable(arcrole);
    this.title = Optional.ofNullable(Strings.emptyToNull(title));
    this.show = Optional.ofNullable(show);
    this.actuate = Optional.ofNullable(actuate);
}

From source file:com.linecorp.armeria.server.docs.EnumValueInfo.java

/**
 * Creates a new instance./*  w  w  w .j av a  2s  . co  m*/
 *
 * @param name the name of the enum value
 * @param docString the documentation string that describes the enum value
 */
public EnumValueInfo(String name, @Nullable String docString) {
    this.name = requireNonNull(name, "name");
    this.docString = Strings.emptyToNull(docString);
}

From source file:org.n52.shetland.ogc.wps.JobStatus.java

public JobStatus(String value) {
    this.value = Objects.requireNonNull(Strings.emptyToNull(value));
}

From source file:com.seyren.mongo.MongoMapper.java

public Check checkFrom(DBObject dbo) {
    String id = dbo.get("_id").toString();
    String name = getString(dbo, "name");
    String description = getString(dbo, "description");
    String target = getString(dbo, "target");
    String from = Strings.emptyToNull(getString(dbo, "from"));
    String until = Strings.emptyToNull(getString(dbo, "until"));
    BigDecimal warn = getBigDecimal(dbo, "warn");
    BigDecimal error = getBigDecimal(dbo, "error");
    boolean enabled = getBoolean(dbo, "enabled");
    boolean live = getOptionalBoolean(dbo, "live", false);
    boolean allowNoData = getOptionalBoolean(dbo, "allowNoData", false);
    AlertType state = AlertType.valueOf(getString(dbo, "state"));
    DateTime lastCheck = getDateTime(dbo, "lastCheck");
    List<Subscription> subscriptions = new ArrayList<Subscription>();
    BasicDBList list = getBasicDBList(dbo, "subscriptions");
    for (Object o : list) {
        subscriptions.add(subscriptionFrom((DBObject) o));
    }/*  w ww.j  a  va 2  s.c  o m*/

    return new Check().withId(id).withName(name).withDescription(description).withTarget(target).withFrom(from)
            .withUntil(until).withWarn(warn).withError(error).withEnabled(enabled).withLive(live)
            .withAllowNoData(allowNoData).withState(state).withLastCheck(lastCheck)
            .withSubscriptions(subscriptions);
}

From source file:org.n52.shetland.ogc.gml.time.IndeterminateValue.java

public IndeterminateValue(String value, String... alias) {
    this.value = Objects.requireNonNull(Strings.emptyToNull(value));
    this.alias = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    this.alias.addAll(Arrays.asList(alias));
    this.alias.add(value);
}