List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty
public static boolean isNotEmpty(final CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
From source file:io.mandrel.requests.proxy.AuthenticatorUtils.java
public static String computeRealmURI(URI uri, boolean useAbsoluteURI, boolean omitQuery) { if (useAbsoluteURI) { return omitQuery && StringUtils.isNotEmpty(uri.getQuery()) ? Uri.create(uri).setQuery(null).toString() : uri.toString();/*from w w w.j a va 2 s. c o m*/ } else { String path = StringUtils.isNotEmpty(uri.getPath()) ? uri.getPath() : "/"; return omitQuery || !StringUtils.isNotEmpty(uri.getQuery()) ? path : path + "?" + uri.getQuery(); } }
From source file:com.kynomics.validators.MyEmailValidator.java
@Override public void validate(FacesContext context, UIComponent uiComponent, Object value) throws ValidatorException { EmailValidator emailValidator = EmailValidator.getInstance(); HtmlInputText htmlInputText = (HtmlInputText) uiComponent; String email = (String) value; if (StringUtils.isNotEmpty(email)) { if (!emailValidator.isValid(email)) { FacesMessage facesMessage = new FacesMessage(htmlInputText.getLabel() + ": email is not valid!"); throw new ValidatorException(facesMessage); }//from w w w .j av a2 s .c o m } }
From source file:com.ppcxy.cyfm.showcase.demos.utilities.string.ApacheStringUtilsDemo.java
@Test public void nullSafe() { // ?// ww w.jav a 2 s . co m assertThat(StringUtils.isNotBlank(null)).isFalse(); assertThat(StringUtils.isNotBlank("")).isFalse(); assertThat(StringUtils.isNotBlank(" ")).isFalse(); assertThat(StringUtils.isNotEmpty(" ")).isTrue(); // nullblankdefault assertThat(StringUtils.defaultString(null)).isEqualTo(""); assertThat(StringUtils.defaultString(null, "defaultStr")).isEqualTo("defaultStr"); assertThat(StringUtils.defaultIfBlank(null, "defaultStr")).isEqualTo("defaultStr"); assertThat(StringUtils.defaultIfBlank(" ", "defaultStr")).isEqualTo("defaultStr"); }
From source file:com.glaf.template.engine.FreemarkerTemplateEngine.java
public static freemarker.template.Template getTemplate(Template template, String encoding) { freemarker.template.Template t = null; try {// w ww . ja v a2s . c o m if (StringUtils.isNotEmpty(template.getContent())) { logger.debug("-----------------------------------"); Reader reader = new BufferedReader(new StringReader(template.getContent())); t = new freemarker.template.Template(template.getDataFile(), reader, configuration); t.setEncoding(encoding); logger.debug("build template engine " + template.getDataFile()); } } catch (IOException ex) { throw new RuntimeException(ex); } return t; }
From source file:com.keybox.common.util.AppConfig.java
/** * gets the property from config and replaces placeholders * * @param name property name//from w w w . j av a2s . c om * @param replacementMap name value pairs of place holders to replace * @return configuration property */ public static String getProperty(String name, Map<String, String> replacementMap) { String value = prop.getString(name); if (StringUtils.isNotEmpty(value)) { //iterate through map to replace text Set<String> keySet = replacementMap.keySet(); for (String key : keySet) { //replace values in string String rVal = replacementMap.get(key); value = value.replace("${" + key + "}", rVal); } } return value; }
From source file:com.mirth.connect.client.ui.panels.export.ExportFormat.java
public String toString() { if (contentType != null) { return StringUtils.isNotEmpty(connectorType) ? connectorType + " - " + contentType.toString() : contentType.toString(); }// ww w.java 2s.com return ""; }
From source file:com.qualys.jserf.SerfResponse.java
public boolean isErrored() { return StringUtils.isNotEmpty(header.getError()); }
From source file:com.netflix.spinnaker.clouddriver.artifacts.config.TokenAuth.java
default Optional<String> getTokenAsString() { String token = null;//from ww w . j av a2s .com if (StringUtils.isNotEmpty(getTokenFile())) { token = CredentialReader.credentialsFromFile(getTokenFile()); } else if (StringUtils.isNotEmpty(getToken())) { token = getToken(); } return Optional.ofNullable(token); }
From source file:com.sixt.service.framework.FeatureFlags.java
public static boolean shouldDisableRpcInstanceRetry(ServiceProperties serviceProps) { String value = serviceProps.getProperty(DISABLE_RPC_INSTANCE_RETRY); if (StringUtils.isNotEmpty(value) && Boolean.valueOf(value)) { return true; } else {/*w w w. j a v a 2 s .c om*/ return false; } }
From source file:net.ostis.scpdev.editors.SequenceRule.java
public static void collectStartsParts(String[] words, Collection<Character> starts, Collection<Character> parts) { Assert.isNotNull(starts);//from w w w . j ava2 s.com for (String word : words) { Assert.isTrue(StringUtils.isNotEmpty(word)); if (starts != null) starts.add(word.charAt(0)); if (parts != null) for (int i = 1; i < word.length(); i++) parts.add(word.charAt(i)); } }