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:com.b2international.snowowl.snomed.importer.rf2.util.EffectiveTimeBaseTransactionAggregatorSupplier.java

@Override
public ICDOTransactionAggregator get(final String from) {

    if (Strings.nullToEmpty(getValue()).equals(from)) {

        return aggregator;

    } else {//from  ww w. j  a  va 2  s  .  c om

        set(from);
        aggregator = CDOTransactionAggregator.create(aggregator);
        return aggregator;

    }

}

From source file:net.anyflow.lannister.message.MessageFactory.java

public static MqttConnectMessage connect(ConnectOptions options) {
    MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNECT, false, MqttQoS.AT_MOST_ONCE,
            false, 10);//from  w  w  w.ja va2s . c  om
    MqttConnectVariableHeader variableHeader = new MqttConnectVariableHeader(options.version().protocolName(),
            options.version().protocolLevel(), options.userName() != null, options.password() != null,
            options.will() == null ? false : options.will().isRetain(),
            options.will() == null ? 0 : options.will().qos().value(), options.will() != null,
            options.cleanSession(), options.keepAliveTimeSeconds());

    MqttConnectPayload payload = new MqttConnectPayload(Strings.nullToEmpty(options.clientId()),
            options.will() == null ? "" : options.will().topicName(),
            options.will() == null ? "" : new String(options.will().message()),
            Strings.nullToEmpty(options.userName()), Strings.nullToEmpty(options.password()));

    return new MqttConnectMessage(fixedHeader, variableHeader, payload);
}

From source file:org.zanata.webtrans.client.ui.HighlightingLabel.java

private void highlight() {
    Element preElement = getElement().getFirstChildElement();
    Highlighting.syntaxHighlight(Strings.nullToEmpty(plainText), preElement);
    preElement.addClassName("cm-s-default");
    String styled = preElement.getInnerHTML().replaceAll("\\n", "<span class='newline'></span>\n");
    preElement.setInnerHTML(styled);/* w  w  w  . j ava  2s . com*/
}

From source file:fathom.shiro.ShiroModule.java

@Override
protected void setup() {

    String configFile = getSettings().getString("shiro.configurationFile", "classpath:conf/shiro.ini");
    Ini ini = Ini.fromResourcePath(configFile);

    IniWebEnvironment webEnvironment = new IniWebEnvironment();
    webEnvironment.setIni(ini);//from  www  .  j  a va2  s  .  c om
    webEnvironment.setServletContext(getServletContext());
    webEnvironment.init();

    bind(WebEnvironment.class).toInstance(webEnvironment);
    bind(SecurityManager.class).toInstance(webEnvironment.getSecurityManager());
    bind(WebSecurityManager.class).toInstance(webEnvironment.getWebSecurityManager());

    String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim();
    filter(basePath + "/*").through(ShiroFilter.class);

    install(new AopModule());
}

From source file:com.b2international.snowowl.snomed.core.mrcm.ConceptModelEcoreValidator.java

private static IStatus createErrorStatus(final String message) {
    return new Status(IStatus.ERROR, SnomedDatastoreActivator.PLUGIN_ID, Strings.nullToEmpty(message));
}

From source file:org.obeonetwork.m2doc.services.LinkServices.java

@Documentation(value = "Converts a String to an hyperlink", params = {
        @Param(name = "text", value = "The label of the link"),
        @Param(name = "url", value = "The destination of the link"), }, result = "A link with the given label that point to the given url.", examples = {
                @Example(expression = "'My website'.asLink('http://www.example.org')", result = "a link to http://www.example.org with the label My website"), })
// @formatter:on/*from  w  w w.  ja  v a  2 s  .co m*/
public MHyperLink asLink(String text, String url) {
    return new MHyperLinkImpl(Strings.nullToEmpty(text), Strings.nullToEmpty(url));
}

From source file:org.opendaylight.aaa.impl.shiro.tokenauthrealm.auth.ClaimBuilder.java

public ClaimBuilder setUser(String userName) {
    user = Strings.nullToEmpty(userName).trim();
    return this;
}

From source file:org.gradle.api.publish.ivy.internal.artifact.AbstractIvyArtifact.java

@Override
public void setName(String name) {
    this.name = Strings.nullToEmpty(name);
}

From source file:com.cloudera.impala.analysis.CreateTableDataSrcStmt.java

/**
 * Creates the initial map of table properties containing the name of the data
 * source and the table init string.//w  w w  .  j  a  v a  2 s.c  om
 */
private static Map<String, String> createInitialTableProperties(String dataSourceName, String initString) {
    Preconditions.checkNotNull(dataSourceName);
    Map<String, String> tableProperties = Maps.newHashMap();
    tableProperties.put(TBL_PROP_DATA_SRC_NAME, dataSourceName.toLowerCase());
    tableProperties.put(TBL_PROP_INIT_STRING, Strings.nullToEmpty(initString));
    return tableProperties;
}

From source file:org.attribyte.api.pubsub.impl.server.util.NotificationRecord.java

/**
 * Creates a notification.//w  w w  .  j  av a 2s . co  m
 * @param request The notification request.
 * @param topicURL The topic the notification was sent to.
 * @param responseCode The HTTP response code sent to the source.
 * @param body The body of the notification.
 */
public NotificationRecord(final HttpServletRequest request, final String topicURL, final int responseCode,
        final byte[] body) {
    this.sourceIP = HTTPUtil.getClientIP(request);
    this.topicURL = Strings.nullToEmpty(topicURL);
    this.responseCode = responseCode;
    this.body = body;
}