List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:org.iplantc.de.desktop.client.views.widgets.TaskButton.java
@Override public void setText(String text) { super.setText(text); if (Strings.nullToEmpty(text).length() > getCell().getAppearance().getMaxTextLength()) { setToolTip(text);/*ww w.j ava 2s . c om*/ } }
From source file:com.salesforce.jprotoc.jdk8.Jdk8Generator.java
private String extractPackageName(DescriptorProtos.FileDescriptorProto proto) { DescriptorProtos.FileOptions options = proto.getOptions(); if (options != null) { String javaPackage = options.getJavaPackage(); if (!Strings.isNullOrEmpty(javaPackage)) { return javaPackage; }/*from www . j a v a 2 s. c o m*/ } return Strings.nullToEmpty(proto.getPackage()); }
From source file:com.android.tools.idea.uibuilder.handlers.menu.ItemHandler.java
@NotNull @Override public String getTitle(@NotNull NlComponent item) { return Strings.nullToEmpty(item.getAndroidAttribute(ATTR_TITLE)); }
From source file:com.zimbra.cs.index.elasticsearch.ElasticSearchConnector.java
public int executeMethod(HttpMethod method) throws IndexStoreException, IOException { String reqBody = ""; if (ZimbraLog.elasticsearch.isTraceEnabled() && method instanceof EntityEnclosingMethod) { EntityEnclosingMethod eem = (EntityEnclosingMethod) method; RequestEntity re = eem.getRequestEntity(); if (re instanceof StringRequestEntity) { StringRequestEntity sre = (StringRequestEntity) re; reqBody = Strings.nullToEmpty(sre.getContent()); if (reqBody.length() > 0) { reqBody = String.format("\nREQUEST BODY=%s", reqBody); }/* w w w . j ava2s . co m*/ } } try { HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient(); statusCode = client.executeMethod(method); } catch (ConnectException ce) { throw new ZimbraElasticSearchDownException(ce); } catch (NoHttpResponseException nhre) { // managed to connect to the ElasticSearch service but it either crashed or timed out before // we got sent back the response. // Could be a temporary problem or a problem with this particular request. // In the longer term we need to track failures related to particular items at a higher level and discard // them after retrying a number of times. throw new ZimbraElasticSearchNoResponseException(nhre); } body = method.getResponseBodyAsString(); ZimbraLog.elasticsearch.trace("ElasticSearch request:%s %s - statusCode=%d%s\nRESPONSE BODY=%s", method.getName(), method.getURI(), statusCode, reqBody, body); return statusCode; }
From source file:org.opendaylight.aaa.impl.shiro.tokenauthrealm.auth.ClaimBuilder.java
public ClaimBuilder addRole(String role) { roles.add(Strings.nullToEmpty(role).trim()); return this; }
From source file:com.google.publicalerts.cap.validator.SubscribeServlet.java
@Override public void doPost(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"); String button = Strings.nullToEmpty(req.getParameter("submit")); // TODO(shakusa) Validate email button = button.toLowerCase();/*from w ww . j a v a 2 s . com*/ Set<CapProfile> profiles = ValidatorUtil.parseProfiles(profileStr); String requestUrl = req.getRequestURL().toString(); String msg = subscribe(button, topic, requestUrl, email, profiles); req.setAttribute("msg", msg); req.setAttribute("topic", topic); req.setAttribute("email", email); req.setAttribute("profiles", ValidatorUtil.getProfilesJsp(profiles)); render(req, resp); }
From source file:net.minecraftforge.client.event.ClientChatEvent.java
public void setMessage(String message) { this.message = Strings.nullToEmpty(message); }
From source file:com.streamsets.datacollector.validation.ValidationUtil.java
/** * Resolve stage aliases (e.g. when a stage is renamed). *///from w w w . ja v a 2 s . c o m public static void resolveStageAlias(StageLibraryTask stageLibrary, StageConfiguration stageConf) { String aliasKey = Joiner.on(",").join(stageConf.getLibrary(), stageConf.getStageName()); String aliasValue = Strings.nullToEmpty(stageLibrary.getStageNameAliases().get(aliasKey)); if (LOG.isTraceEnabled()) { for (String key : stageLibrary.getStageNameAliases().keySet()) { LOG.trace("Stage Lib Alias: {} => {}", key, stageLibrary.getStageNameAliases().get(key)); } LOG.trace("Looking for '{}' and found '{}'", aliasKey, aliasValue); } if (!aliasValue.isEmpty()) { List<String> alias = Splitter.on(",").splitToList(aliasValue); if (alias.size() == 2) { LOG.debug("Converting '{}' to '{}'", aliasKey, aliasValue); stageConf.setLibrary(alias.get(0)); stageConf.setStageName(alias.get(1)); } else { LOG.error("Malformed stage alias: '{}'", aliasValue); } } }
From source file:org.jclouds.aws.ec2.xml.TagSetHandler.java
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equals("item")) { inItem = false;// w w w . j a v a2 s . com if (key != null) { result.put(key, Strings.nullToEmpty(value)); } } if (inItem) { if (qName.equals("key")) { key = currentOrNull(currentText); } else if (qName.equals("value")) { value = currentOrNull(currentText); } } }
From source file:io.druid.query.lookup.LookupExtractionFn.java
@JsonCreator public LookupExtractionFn(@JsonProperty("lookup") final LookupExtractor lookup, @JsonProperty("retainMissingValue") final boolean retainMissingValue, @Nullable @JsonProperty("replaceMissingValueWith") final String replaceMissingValueWith, @JsonProperty("injective") final boolean injective, @JsonProperty("optimize") Boolean optimize) { super(new Function<String, String>() { @Nullable/* w w w. j a va2 s. c o m*/ @Override public String apply(String input) { return lookup.apply(Strings.nullToEmpty(input)); } }, retainMissingValue, replaceMissingValueWith, injective); this.lookup = lookup; this.optimize = optimize == null ? true : optimize; this.retainMissingValue = retainMissingValue; this.injective = injective; this.replaceMissingValueWith = replaceMissingValueWith; }