List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:biz.ganttproject.core.option.FontSpec.java
public String asString() { return String.format("%s-%s", Strings.nullToEmpty(myFamily), mySize.toString()); }
From source file:br.edu.utfpr.cm.JGitMinerWeb.services.matriz.auxiliary.AuxWordiness.java
public void setWordiness() { this.wordiness += LuceneUtil.tokenizeString(Strings.nullToEmpty(getIssueBody())).size(); for (EntityComment entityComment : comments) { this.wordiness += LuceneUtil.tokenizeString(Strings.nullToEmpty(entityComment.getBody())).size(); }/*from w w w .ja va 2 s. co m*/ }
From source file:org.gradle.api.publish.maven.internal.artifact.AbstractMavenArtifact.java
public final void setExtension(String extension) { this.extension = Strings.nullToEmpty(extension); }
From source file:org.jclouds.fujitsu.fgcp.xml.BindParamsToXmlPayload.java
@SuppressWarnings("unchecked") @Override/*w w w. java2s .co m*/ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> mapParams) { String action = checkNotNull(mapParams.remove(RequestParameters.ACTION), RequestParameters.ACTION) .toString(); String version = Strings.nullToEmpty((String) mapParams.remove(RequestParameters.VERSION)); StringBuilder xml = new StringBuilder(); xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); xml.append("<OViSSRequest>\r\n"); xml.append(" <Action>" + action + "</Action>\r\n"); for (Map.Entry<String, Object> entry : mapParams.entrySet()) { String key = entry.getKey(); xml.append(" <" + key + ">" + checkNotNull(mapParams.get(key)) + "</" + key + ">\r\n"); } xml.append(" <Version>" + version + "</Version>\r\n"); xml.append(" <Locale></Locale>\r\n"); // value inserted in // RequestAuthenticator#filter xml.append(" <AccessKeyId></AccessKeyId>\r\n"); // value inserted in // RequestAuthenticator#filter xml.append(" <Signature></Signature>\r\n"); // value inserted in // RequestAuthenticator#filter xml.append("</OViSSRequest>"); request = super.bindToRequest(request, xml); request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_XML); // remove version query param if set as it was moved to the xml body URI uri = request.getEndpoint(); URI uriWithoutQueryParams; try { uriWithoutQueryParams = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), null, uri.getFragment()); } catch (URISyntaxException e) { // should never happen as we're copying the components from a URI uriWithoutQueryParams = uri; } return (R) request.toBuilder().endpoint(uriWithoutQueryParams).build(); }
From source file:org.carrot2.source.microsoft.Bing3WebDocumentSource.java
/** * Process the query./*from w w w. ja v a2s. co m*/ */ @Override public void process() throws ProcessingException { if (!Strings.isNullOrEmpty(site)) { query = Strings.nullToEmpty(query) + " site:" + site; } super.process(metadata, getSharedExecutor(MAX_CONCURRENT_THREADS, getClass())); }
From source file:com.android.ide.common.blame.output.BlameRewritingLogger.java
@Override public void error(@Nullable Throwable t, @Nullable String msgFormat, Object... args) { mLogger.error(t, mGradleMessageRewriter.rewriteMessages(Strings.nullToEmpty(msgFormat)), args); }
From source file:org.apache.sentry.tests.e2e.hiveserver.AbstractHiveServer.java
protected static void waitForStartup(HiveServer hiveServer) throws Exception { int waitTime = 0; long startupTimeout = 1000L * 10L; do {//from w w w . j a va 2 s . co m Thread.sleep(500L); waitTime += 500L; if (waitTime > startupTimeout) { throw new TimeoutException("Couldn't access new HiveServer: " + hiveServer.getURL()); } try { Connection connection = DriverManager.getConnection(hiveServer.getURL(), "hive", "bar"); connection.close(); break; } catch (SQLException e) { String state = Strings.nullToEmpty(e.getSQLState()).trim(); if (!state.equalsIgnoreCase(LINK_FAILURE_SQL_STATE)) { throw e; } } } while (true); }
From source file:org.graylog.plugins.pipelineprocessor.functions.strings.Concat.java
@Override public String evaluate(FunctionArgs args, EvaluationContext context) { final String first = Strings.nullToEmpty(firstParam.required(args, context)); final String second = Strings.nullToEmpty(secondParam.required(args, context)); return first.concat(second); }
From source file:org.apache.druid.common.config.NullHandling.java
@Nullable public static String nullToEmptyIfNeeded(@Nullable String value) { //CHECKSTYLE.OFF: Regexp return replaceWithDefault() ? Strings.nullToEmpty(value) : value; //CHECKSTYLE.ON: Regexp }
From source file:gobblin.converter.string.StringFilterConverter.java
@Override public Converter<Class<String>, Class<String>, String, String> init(WorkUnitState workUnit) { this.pattern = Pattern.compile(Strings.nullToEmpty(workUnit.getProp(ForkOperatorUtils .getPropertyNameForBranch(workUnit, ConfigurationKeys.CONVERTER_STRING_FILTER_PATTERN)))); this.matcher = Optional.absent(); return this; }