List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:com.google.publicalerts.cap.validator.SubscribeServlet.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String topic = Strings.nullToEmpty(req.getParameter("topic")); String email = Strings.nullToEmpty(req.getParameter("email")); String profileStr = req.getParameter("profiles"); req.setAttribute("msg", null); req.setAttribute("topic", topic); req.setAttribute("email", email); req.setAttribute("profiles", ValidatorUtil.getProfilesJsp(ValidatorUtil.parseProfiles(profileStr))); render(req, resp);//from ww w.j a v a 2 s . com }
From source file:com.ericsson.gerrit.plugins.syncindex.Configuration.java
@Inject Configuration(PluginConfigFactory config, @PluginName String pluginName) { PluginConfig cfg = config.getFromGerritConfig(pluginName, true); url = Strings.nullToEmpty(cfg.getString("url")); user = Strings.nullToEmpty(cfg.getString("user")); password = Strings.nullToEmpty(cfg.getString("password")); connectionTimeout = cfg.getInt("connectionTimeout", DEFAULT_TIMEOUT_MS); socketTimeout = cfg.getInt("socketTimeout", DEFAULT_TIMEOUT_MS); maxTries = cfg.getInt("maxTries", DEFAULT_MAX_TRIES); retryInterval = cfg.getInt("retryInterval", DEFAULT_RETRY_INTERVAL); threadPoolSize = cfg.getInt("threadPoolSize", DEFAULT_THREAD_POOL_SIZE); }
From source file:org.attribyte.metrics.MetricField.java
/** * Gets a metric field from a string value. * @param str The string value./* w w w.ja v a 2 s .c o m*/ * @return The metric field or <code>UNKNOWN</code>. */ public static final MetricField fromString(final String str) { switch (Strings.nullToEmpty(str).trim().toLowerCase().replace('-', '_').replace(' ', '_')) { case "count": return COUNT; case "one_minute_rate": case "1m_rate": return ONE_MINUTE_RATE; case "five_minute_rate": case "5m_rate": return FIVE_MINUTE_RATE; case "fifteen_minute_rate": case "15m_rate": return FIFTEEN_MINUTE_RATE; case "mean_rate": return MEAN_RATE; case "median": case "p50": case "50th": case "50th_%": case "50th_percentile": return MEDIAN; case "p75": case "75th": case "75th_%": case "75th_percentile": return P75; case "p95": case "95th": case "95th_%": case "95th_percentile": return P95; case "p98": case "98th": case "98th_%": case "98th_percentile": return P98; case "p99": case "99th": case "99th_%": case "99th_percentile": return P99; case "p999": case "99.9th": case "99.9th_%": case "99.9th_percentile": return P999; case "max": return MAX; case "mean": case "avg": return MEAN; case "min": return MIN; case "std": case "standard_deviation": return STD; case "value": return VALUE; default: return UNKNOWN; } }
From source file:io.druid.segment.filter.ExtractionFilter.java
public ExtractionFilter(String dimension, String value, ExtractionFn fn) { this.dimension = dimension; this.value = Strings.nullToEmpty(value); this.fn = fn; }
From source file:br.edu.utfpr.cm.JGitMinerWeb.services.metric.social.WordinessMetric.java
@Override public void calculateMetric(AuxAllMetrics pairOfFile) { List<EntityUser> userSetListTemp = new ArrayList<>(); if (!pairOfFile.getRepoCommits().isEmpty()) { for (EntityRepositoryCommit repositoryCommit : pairOfFile.getRepoCommits()) { int wordiness = 0; for (EntityCommitComment comment : repositoryCommit.getComments()) { wordiness += LuceneUtil.tokenizeString(Strings.nullToEmpty(comment.getBody())).size(); }//from w w w. j a va 2 s .c om setResult(pairOfFile, wordiness); } } if (!pairOfFile.getPullRequests().isEmpty()) { for (EntityPullRequest pullRequest : pairOfFile.getPullRequests()) { int wordiness = 0; wordiness += LuceneUtil.tokenizeString(Strings.nullToEmpty(pullRequest.getBody())).size(); try { for (EntityComment comment : pullRequest.getIssue().getComments()) { wordiness += LuceneUtil.tokenizeString(Strings.nullToEmpty(comment.getBody())).size(); } } catch (Exception e) { System.out.println("Erro"); System.out.println(e.toString()); } setResult(pairOfFile, wordiness); } } }
From source file:io.macgyver.plugin.metrics.RegexMetricFilter.java
public RegexMetricFilter includes(String s) { Splitter.on(CharMatcher.anyOf(" \n\t\r,;|")).omitEmptyStrings().splitToList(Strings.nullToEmpty(s)) .forEach(it -> {//from www . j a v a2 s. c o m include(Pattern.compile(it)); }); return this; }
From source file:com.skcraft.launcher.model.modpack.Feature.java
@Override public int compareTo(Feature o) { return Strings.nullToEmpty(getName()).compareTo(Strings.nullToEmpty(o.getName())); }
From source file:net.monofraps.gradlecurse.extensions.CurseDeploy.java
public String getGameHandle() { return Strings.nullToEmpty(gameHandle); }
From source file:br.edu.utfpr.cm.JGitMinerWeb.services.matriz.auxiliary.AuxNumberOfLinks.java
public void setNumberOflinks() { this.numberOflinks += UrlValidator.urlInString(Strings.nullToEmpty(getIssueBody())); for (EntityComment entityComment : comments) { this.numberOflinks += UrlValidator.urlInString(Strings.nullToEmpty(entityComment.getBody())); }//from w w w. j a v a2 s . c o m }
From source file:org.spc.ofp.tubs.importer.ExistsFilterProcessor.java
public String process(final String input) throws Exception { Preconditions.checkNotNull(input, "Source Trip Id is null"); Preconditions.checkArgument(!"".equalsIgnoreCase(input.trim()), "Source Trip Id is blank"); // Not really the caller's fault, but still nothing we can do... if (Strings.isNullOrEmpty(Strings.nullToEmpty(sourceName).trim())) { return null; }// w ww .j a va 2 s . c om ImportStatus is = null; try { is = repo.findImportStatus(input, sourceName); } catch (Exception ignoreMe) { } // NOPMD // Status of 'S' is success, anything else is 'go for it' return (null != is && "S".equalsIgnoreCase(is.getStatus())) ? null : input; }