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.obm.push.mail.MailViewToMSEmailConverterImpl.java

private String convertSubject(EmailView emailView) {
    ICalendar iCalendar = emailView.getICalendar();
    if (iCalendar != null && iCalendar.hasEvent()) {
        String iCalendarSummary = iCalendar.getICalendarEvent().summary();
        return Strings.emptyToNull(iCalendarSummary);
    }/*from  ww w.j  av a 2  s.  c  o m*/
    return emailView.getSubject();
}

From source file:com.commercehub.bamboo.plugins.grailswrapper.GrailsWrapperTask.java

@NotNull
private Map<String, String> buildEnvironment(@NotNull TaskContext taskContext) {
    ConfigurationMap configurationMap = taskContext.getConfigurationMap();
    Map<String, String> environment = Maps.newHashMap(environmentVariableAccessor.getEnvironment(taskContext));
    Properties properties = loadEnvironmentProperties(taskContext);
    for (String key : properties.stringPropertyNames()) {
        environment.put(key, properties.getProperty(key));
    }//www.  j  a v a2 s.c om
    String javaHome = getJavaHome(taskContext);
    String javaOpts = Strings.emptyToNull(configurationMap.get(GrailsWrapperTaskConfigurator.JVM_OPTIONS));
    if (javaHome != null) {
        environment.put("JAVA_HOME", javaHome);
    }
    if (javaOpts != null) {
        environment.put("JAVA_OPTS", javaOpts);
    }
    return environment;
}

From source file:org.dcache.services.billing.db.impl.BaseBillingInfoAccess.java

public void setDelegateType(String delegateType) {
    this.delegateType = Strings.emptyToNull(delegateType);
}

From source file:org.sonatype.nexus.jmx.internal.ManagedObjectRegistrar.java

/**
 * Determine object-name 'name' value./*  w  ww . jav a  2s  .  co  m*/
 */
@Nullable
private String name(final ManagedObject descriptor, final BeanEntry<Annotation, Object> entry) {
    String name = Strings.emptyToNull(descriptor.name());
    if (name == null) {
        Class<?> type = entry.getImplementationClass();

        // use @Named entry-key if possible, this will be filled in by sisu
        if (entry.getKey() instanceof Named) {
            Named named = (Named) entry.getKey();

            // if named-value is NOT the same as the impl-type-name then use it
            // ie. if org.sonatype.nexus.FooImpl == org.sonatype.nexus.FooImpl, then leave name as null
            if (!type.getName().equals(named.value())) {
                name = Strings.emptyToNull(named.value());
            }
        }

        // else lookup @Named directly unable to determine from entry-key
        if (name == null) {
            Named named = entry.getImplementationClass().getAnnotation(Named.class);
            if (named != null) {
                name = Strings.emptyToNull(named.value());
            }
        }
    }
    return name;
}

From source file:org.onosproject.netconf.NetconfRpcError.java

@Override
public String toString() {
    return MoreObjects.toStringHelper(this).add("type", type()).add("tag", tag()).add("severity", severity())
            .add("appTag", appTag().orElse(null)).add("path", path().orElse(null))
            .add("message", Strings.emptyToNull(message())).add("info-session-id", infoSessionId().orElse(null))
            .add("info", info()).omitNullValues().toString();
}

From source file:org.dcache.alarms.server.LogEntryServerWrapper.java

public void setEmailUser(String emailUser) {
    this.emailUser = Strings.emptyToNull(emailUser);
}

From source file:org.apache.druid.java.util.common.StringUtils.java

/**
 * Returns the given string if it is nonempty; {@code null} otherwise.
 * This method should only be used at places where null to empty conversion is
 * irrelevant to null handling of the data.
 *
 * @param string the string to test and possibly return
 *
 * @return {@code string} itself if it is nonempty; {@code null} if it is
 * empty or null//ww  w  .j av a 2 s.c  om
 */
@Nullable
public static String emptyToNullNonDruidDataString(@Nullable String string) {
    //CHECKSTYLE.OFF: Regexp
    return Strings.emptyToNull(string);
    //CHECKSTYLE.ON: Regexp
}

From source file:com.kik.config.ice.source.FileDynamicConfigSource.java

@VisibleForTesting
static ConfigChangeEvent<String> parseLine(String line) {
    if (Strings.isNullOrEmpty(line)) {
        return null;
    }//  w w w. ja  v a2s  . c o m
    Matcher matcher = CONFIG_LINE_PATTERN.matcher(line.trim());
    if (!matcher.matches()) {
        return null;
    }
    return new ConfigChangeEvent<>(matcher.group("key"),
            Optional.ofNullable(Strings.emptyToNull(matcher.group("value"))));
}

From source file:org.activityinfo.server.command.handler.BaseEntityHandler.java

private String trim(Object value) {
    if (value instanceof String) {
        String stringValue = (String) value;
        return Strings.emptyToNull(stringValue.trim());
    } else {//ww w .j  av a2s . c  o  m
        return null;
    }
}

From source file:org.dcache.alarms.server.LogEntryServerWrapper.java

public void setLevel(String level) {
    this.level = Strings.emptyToNull(level);
}