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.zanata.sync.jobs.common.model.UsernamePasswordCredential.java

public UsernamePasswordCredential(String username, String secret) {
    this.username = Strings.nullToEmpty(username);
    this.secret = Strings.nullToEmpty(secret);
}

From source file:pzalejko.iot.hardware.home.core.service.configuration.DefaultTemperatureConfiguration.java

public DefaultTemperatureConfiguration(Properties properties) {
    checkNotNull(properties);//from  w ww .j  a v a 2  s .co m
    readFrequency = Long.parseLong(Strings.nullToEmpty(properties.getProperty(READ_FREQ_KEY)));
    sourceFilePath = Strings.nullToEmpty(properties.getProperty(SOURCE_DICTIONARY_KEY));
    fileName = Strings.nullToEmpty(properties.getProperty(SOURCE_FILE_NAME_KEY));

    checkArgument(readFrequency > 0);
    checkArgument(!sourceFilePath.isEmpty(),
            MessageFormat.format(LogMessages.TEMP_SERVICE_MISSING_PROPERTY, SOURCE_DICTIONARY_KEY));
    checkArgument(!fileName.isEmpty(),
            MessageFormat.format(LogMessages.TEMP_SERVICE_MISSING_PROPERTY, SOURCE_FILE_NAME_KEY));
}

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

@Override
public void setSearchText(String searchText) {
    runtime.getItemListOverlay().setFilterText(Strings.nullToEmpty(searchText));
}

From source file:com.google.testing.security.firingrange.tests.reverseclickjacking.UniversalReverseClickjackingJsonpEndpoint.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String echoedParam = Strings.nullToEmpty(request.getParameter(ECHOED_PARAM));
    if (!echoedParam.matches(CALLBACK_REGEX) || echoedParam.length() > MAX_CALLBACK_LENGTH) {
        Responses.sendError(response,//from w w w . java2  s.c  om
                "Invalid callback value: can only contain alphanumeric characters, dots and underscores.", 400);
    } else {
        // Prefix the callback with /**/ to avoid Rosetta Flash-like attacks
        String json = "/**/" + echoedParam + "({'foobar':'foo'});";
        Responses.sendXssed(response, json, "application/json");
    }
}

From source file:com.google.idea.blaze.java.sync.source.FilePathJavaPackageReader.java

@Override
public String getDeclaredPackageOfJavaFile(BlazeContext context,
        ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
    String parentPath = new File(sourceArtifact.artifactLocation.relativePath).getParent();
    return PackagePrefixCalculator.packagePrefixOf(new WorkspacePath(Strings.nullToEmpty(parentPath)));
}

From source file:org.gbif.ws.server.filter.RequestHeaderParamUpdateFilter.java

private static void processJsonp(HttpRequestContext request) {
    String callback = Strings.nullToEmpty(request.getQueryParameters().getFirst("callback")).trim();
    if (!callback.isEmpty()) {
        // this is a jsonp request - force content type to javascript
        request.getRequestHeaders().putSingle(HttpHeaders.ACCEPT, ExtraMediaTypes.APPLICATION_JAVASCRIPT);
    }//  www.  j  ava  2 s . c o  m
}

From source file:net.monofraps.gradlebukkit.extensions.RemoteDebugging.java

public String getJvmArguments() {
    jvmArguments = Strings.nullToEmpty(jvmArguments);
    Preconditions.checkArgument(!jvmArguments.isEmpty(), "Parameter jvmArguments must not be null nor empty.");

    return jvmArguments.replace("$transport$", getDebuggingTransport().toString()).replace("$address$",
            address);/*from  w  w  w .  ja va2s .c  o  m*/
}

From source file:fr.da2i.lup1.util.SimpleResource.java

protected String getAuthenticatedLogin() {
    return Strings.nullToEmpty(securityContext.getUserPrincipal().getName());
}

From source file:com.google.testing.junit.runner.junit4.RegExTestCaseFilter.java

private static String formatDescriptionName(Description description) {
    String methodName = Strings.nullToEmpty(description.getMethodName());
    String className = Strings.nullToEmpty(description.getClassName());
    if (methodName.trim().isEmpty() || className.trim().isEmpty()) {
        return description.getDisplayName();
    }/*from  w  w w. j  a  v  a  2  s . co  m*/
    return String.format(TEST_NAME_FORMAT, className, methodName);
}

From source file:org.radonix.moted.service.PreviewService.java

public void preview(SourceEditor editor, final ResultViewer viewer) {
    final String source = editor.getSource();
    executeTask(new Task<String>() {
        @Override/*  w ww  . java  2s  . c o m*/
        public String atWorking() throws Exception {
            String result = processor.process(source);
            return Strings.nullToEmpty(result);
        }

        @Override
        public void onSuccess(String result) {
            viewer.viewResult(result);
        }

        @Override
        public void onFailure(Exception e) {
            Log.e(TAG, "Cannot process the markdown source.", e);
        }
    });
}