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

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

Introduction

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

Prototype

public static String nullToEmpty(@Nullable String string) 

Source Link

Document

Returns the given string if it is non-null; the empty string otherwise.

Usage

From source file:org.graylog.plugins.metrics.gelf.converters.GelfTransportsConverter.java

@Override
public GelfTransports convertFrom(String value) {
    try {//from  w  w  w  .j  a  v a 2  s.c  o  m
        return GelfTransports.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException e) {
        throw new ParameterException("Couldn't convert value \"" + value + "\" to GELF transport.", e);
    }
}

From source file:org.graylog.plugins.metrics.gelf.converters.GelfMessageLevelConverter.java

@Override
public GelfMessageLevel convertFrom(String value) {
    try {//  ww  w.  j a  v  a  2s  .  co m
        return GelfMessageLevel.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException e) {
        throw new ParameterException("Couldn't convert value \"" + value + "\" to GELF message level.", e);
    }
}

From source file:com.indeed.imhotep.sql.ast2.QueryParts.java

public QueryParts(String from, String where, String groupBy, String select, String limit) {
    this.from = Strings.nullToEmpty(from).trim();
    this.where = Strings.nullToEmpty(where).trim();
    this.groupBy = Strings.nullToEmpty(groupBy).trim();
    this.select = Strings.nullToEmpty(select).trim();
    this.limit = Strings.nullToEmpty(limit).trim();
}

From source file:com.github.jsdossier.Parameter.java

Parameter(@Nullable String name, @Nullable JSTypeExpression type, @Nullable String description) {
    this.name = nullToEmpty(name);
    this.type = type;
    this.description = Strings.nullToEmpty(description);
}

From source file:com.eucalyptus.auth.euare.common.oidc.OIDCUtils.java

/**
 * Parse a provider url and throw if invalid.
 *
 * @param issuerIdentifier The URL (must start with "https://")
 * @return A tuple of the host, port and path for the provider
 * @throws IllegalArgumentException If the url is invalid
 *///from  w  w w.  j ava 2s. c om
public static OIDCIssuerIdentifier parseIssuerIdentifier(final String issuerIdentifier)
        throws IllegalArgumentException {
    try {
        if (issuerIdentifier == null) {
            throw new IllegalArgumentException("Null issuer identifier");
        }
        final URI uri = new URI(issuerIdentifier);
        if (!"https".equalsIgnoreCase(uri.getScheme()) && !"http".equalsIgnoreCase(uri.getScheme())) {
            throw new IllegalArgumentException(
                    "Invalid scheme " + uri.getScheme() + " for issuer identifier: " + issuerIdentifier);
        }
        if (uri.getQuery() != null || uri.getFragment() != null) {
            throw new IllegalArgumentException("Query or fragment not permitted: " + issuerIdentifier);
        }
        return new OIDCIssuerIdentifier(uri.getHost(), uri.getPort(), Strings.nullToEmpty(uri.getPath())); //TODO:STEVE: what about only /?
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}

From source file:org.graylog.plugins.metrics.slf4j.converters.LoggingLevelConverter.java

@Override
public Slf4jReporter.LoggingLevel convertFrom(String value) {
    try {/*from www .  j  a  v  a2s .c o  m*/
        return Slf4jReporter.LoggingLevel.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException e) {
        throw new ParameterException("Couldn't convert value \"" + value + "\" to log level.", e);
    }
}

From source file:appeng.integration.modules.jei.JeiRuntimeAdapter.java

@Override
public String getSearchText() {
    return Strings.nullToEmpty(runtime.getItemListOverlay().getFilterText());
}

From source file:org.graylog.plugins.metrics.datadog.converters.DatadogTransportConverter.java

@Override
public DatadogTransport convertFrom(String value) {
    try {//from  w w w . j  a v  a 2 s  .  c o m
        return DatadogTransport.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException e) {
        throw new ParameterException("Couldn't convert value \"" + value + "\" to Datadog transport.", e);
    }
}

From source file:com.google.testing.security.firingrange.tests.reflected.JsonContentSniffingCallback.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String echoedParam = Strings.nullToEmpty(request.getParameter(ECHOED_PARAM));
    String json;//www. j a  v  a2s  .  c  o m
    if (echoedParam.isEmpty()) {
        json = "{'foobar':'foo'}";
    } else {
        json = echoedParam + "({'foobar':'foo'});";
    }
    Responses.sendXssed(response, json, "application/json");
}

From source file:org.graylog.plugins.metrics.graphite.converters.GraphiteProtocolConverter.java

@Override
public GraphiteProtocol convertFrom(String value) {
    try {/*  w w w .ja  v a2 s .  c om*/
        return GraphiteProtocol.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException e) {
        throw new ParameterException("Couldn't convert value \"" + value + "\" to Graphite protocol.", e);
    }
}