List of usage examples for com.google.common.base Strings emptyToNull
@Nullable public static String emptyToNull(@Nullable String string)
From source file:com.google.gerrit.server.project.CommentLinkInfoImpl.java
public CommentLinkInfoImpl(String name, String match, String link, String html, Boolean enabled) { checkArgument(name != null, "invalid commentlink.name"); checkArgument(!Strings.isNullOrEmpty(match), "invalid commentlink.%s.match", name); link = Strings.emptyToNull(link); html = Strings.emptyToNull(html);//from w w w .java 2s .c o m checkArgument((link != null && html == null) || (link == null && html != null), "commentlink.%s must have either link or html", name); this.name = name; this.match = match; this.link = link; this.html = html; this.enabled = enabled; }
From source file:org.n52.shetland.ogc.sos.ObjectWithXmlString.java
public void setXml(String xml) { this.xml = Optional.of(Strings.emptyToNull(xml)); }
From source file:net.minecrell.serverlistplus.core.status.hosts.VirtualHostAddress.java
public VirtualHostAddress(String host, Integer port) { this.host = Strings.emptyToNull(host); this.port = port; this.address = host != null && port != null ? new InetSocketAddress(host, port) : null; }
From source file:com.github.ykrasik.jerminal.internal.util.StringUtils.java
/** * Transforms an all-whitespace string to an absent value. * * @param str String to check./*from www .j av a2 s .c o m*/ * @return A present value if the string had any non-whitespace character, or an absent value otherwise. */ public static Optional<String> getOptionalString(String str) { return Optional.fromNullable(Strings.emptyToNull(str.trim())); }
From source file:com.google.gerrit.server.account.DefaultRealm.java
@Override public boolean allowsEdit(final AccountFieldName field) { if (authConfig.getAuthType() == AuthType.HTTP) { switch (field) { case USER_NAME: return false; case FULL_NAME: return Strings.emptyToNull(authConfig.getHttpDisplaynameHeader()) == null; case REGISTER_NEW_EMAIL: return authConfig.isAllowRegisterNewEmail() && Strings.emptyToNull(authConfig.getHttpEmailHeader()) == null; default:/*w ww . j ava 2 s . c om*/ return true; } } switch (field) { case REGISTER_NEW_EMAIL: return authConfig.isAllowRegisterNewEmail(); case FULL_NAME: case USER_NAME: default: return true; } }
From source file:com.google.gerrit.server.account.GetSshKeys.java
public static SshKeyInfo newSshKeyInfo(AccountSshKey sshKey) { SshKeyInfo info = new SshKeyInfo(); info.seq = sshKey.getKey().get();// w w w. j a va 2s.com info.sshPublicKey = sshKey.getSshPublicKey(); info.encodedKey = sshKey.getEncodedKey(); info.algorithm = sshKey.getAlgorithm(); info.comment = Strings.emptyToNull(sshKey.getComment()); info.valid = sshKey.isValid(); return info; }
From source file:tech.beshu.ror.acl.blocks.rules.impl.RorKbnAuthSyncRule.java
private static Optional<String> extractToken(String authHeader) { if (authHeader.startsWith("Bearer ")) { String token = authHeader.substring(7).trim(); return Optional.ofNullable(Strings.emptyToNull(token)); }/*from w w w . j a v a2s . c o m*/ return Optional.ofNullable(Strings.emptyToNull(authHeader)); }
From source file:org.kew.rmf.reconciliation.queryextractor.CitationToPropertiesConverter.java
@Override public Property[] extractProperties(String queryString) { /*/*ww w .j a va2 s.c o m*/ * Expected format: * Publication abbreviation [Authors], (YEAR). */ queryString.replace(" ", " "); String publication = null, authors = null, date = null; if (queryString != null) { java.util.regex.Matcher m = pattern.matcher(queryString); if (m.find()) { publication = m.group(1).trim(); authors = Strings.emptyToNull(m.group(3)); date = Strings.emptyToNull(m.group(5)); } } return makeProperties(publication, authors, date); }
From source file:com.google.gitiles.doc.MarkdownConfig.java
MarkdownConfig(Config cfg) { render = cfg.getBoolean("markdown", "render", true); inputLimit = cfg.getInt("markdown", "inputLimit", 5 << 20); imageLimit = cfg.getInt("markdown", "imageLimit", IMAGE_LIMIT); analyticsId = Strings.emptyToNull(cfg.getString("google", null, "analyticsId")); String[] f = cfg.getStringList("markdown", null, "allowiframe"); allowAnyIFrame = f.length == 1 && StringUtils.toBooleanOrNull(f[0]) == Boolean.TRUE; if (allowAnyIFrame) { allowIFrame = ImmutableList.of(); } else {//from w ww . j av a 2 s . c o m allowIFrame = ImmutableList.copyOf(f); } }
From source file:org.jboss.gwt.elemento.processor.context.DataElementInfo.java
public DataElementInfo(final String type, final String name, final String selector, final Kind kind, boolean returnedByMethod) { this.type = type; this.name = name; this.selector = Strings.emptyToNull(selector) == null ? name : selector; this.kind = kind; this.returnedByMethod = returnedByMethod; }