List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:com.github.ferstl.maven.pomenforcers.util.EnforcerRuleUtils.java
public static String evaluateProperties(String input, EnforcerRuleHelper helper) { if (!Strings.isNullOrEmpty(input)) { Matcher matcher = PROPERTY_PATTERN.matcher(input); StringBuffer substituted = new StringBuffer(); while (matcher.find()) { String property = matcher.group(); matcher.appendReplacement(substituted, evaluateStringProperty(property, helper)); }//w w w. j a va 2 s .co m matcher.appendTail(substituted); return substituted.toString(); } return input; }
From source file:uk.co.q3c.v7.base.config.ConfigUtil.java
/** * /*from w w w. j a v a2 s. co m*/ * @param base * the base of the path, for example <code>$user.home</code>. Must be prefixed with $, and will be * expanded using {@link System#getProperty()}. Null or empty is ignored * @param directory * the directory within base, or if base is not specified, within default directory. Can be null or * empty. * @param filename * The filename. Cannot be null or empty * @return */ public static File fileFromPathWithVariable(String base, String directory, String filename) { File d; if (!Strings.isNullOrEmpty(base)) { File b = new File(expandProperty(base)); d = new File(b, directory); } else { d = new File(directory); } File f = new File(d, filename); return f; }
From source file:org.xacml4j.v30.types.StringExp.java
/** * Creates {@link StringExp} from given string instance * * @param v a string value/*from w ww. j a v a 2 s . c o m*/ * @return {@link StringExp} * @exception IllegalArgumentException if given * string value is null or empty */ public static StringExp of(String v) { Preconditions.checkArgument(!Strings.isNullOrEmpty(v)); return new StringExp(v); }
From source file:io.druid.common.utils.UUIDUtils.java
/** * Generates a universally unique identifier. * * @param extraData Extra data which often takes the form of debugging information * * @return A string which is a universally unique id (as determined by java.util.UUID) with extra data. It does not conform to a UUID variant standard. */// w w w .j a v a 2 s.c om public static String generateUuid(String... extraData) { String extra = null; if (extraData != null && extraData.length > 0) { final ArrayList<String> extraStrings = new ArrayList<>(extraData.length); for (String extraString : extraData) { if (!Strings.isNullOrEmpty(extraString)) { extraStrings.add(extraString); } } if (!extraStrings.isEmpty()) { extra = Joiner.on(UUID_DELIM).join(extraStrings); } } final String uuid = UUID.randomUUID().toString().replace("-", ""); // We don't use "-" in general, so remove them here. return extra == null ? uuid : (extra + UUID_DELIM + uuid); }
From source file:com.addthis.hydra.job.web.KVUtils.java
private static String findFirstNonEmptyValue(KVPairs kv, String[] keys) { for (String key : keys) { if (kv.hasKey(key)) { String v = kv.getValue(key); if (!Strings.isNullOrEmpty(v)) { return v; }//from w w w . j a va2 s. c o m } } return null; }
From source file:org.glowroot.DataDir.java
public static File getDataDir(Map<String, String> properties, @Nullable File glowrootJarFile) { String dataDirPath = properties.get("data.dir"); if (glowrootJarFile == null) { // this is only for test support checkNotNull(dataDirPath, "Property data.dir is required when no glowroot jar file"); return new File(dataDirPath); }/*from w w w . j a v a 2s. c o m*/ // empty check to support parameterized script, e.g. -Dglowroot.data.dir=${somevar} if (Strings.isNullOrEmpty(dataDirPath)) { return getDefaultDataDir(glowrootJarFile); } File dataDir = new File(dataDirPath); if (!dataDir.isAbsolute()) { return getRelativeDataDir(dataDirPath, glowrootJarFile); } return getAbsoluteDataDir(dataDir); }
From source file:com.fanmei.pay4j.util.StringUtil.java
public static String unCapitalize(final String str) { if (Strings.isNullOrEmpty(str)) { return str; }/*from w w w . j a v a 2 s.c o m*/ char firstChar = str.charAt(0); if (Character.isLowerCase(firstChar)) { return str; } int strLen = str.length(); return new StringBuilder(strLen).append(Character.toLowerCase(firstChar)).append(str.substring(1)) .toString(); }
From source file:org.shaf.server.tag.FrameTag.java
/** * Generates the form ID for the specified name. * /*from w ww.j ava 2 s .c o m*/ * @param name * the form name. * @return the generated form ID. */ public static final String generateId(final String name) { if (Strings.isNullOrEmpty(name)) { return "formDefault"; } else { StringBuilder id = new StringBuilder("form"); for (String word : name.split("\\s")) { id.append(word.substring(0, 1).toUpperCase()); id.append(word.substring(1).toLowerCase()); } return id.toString(); } }
From source file:com.infinities.keystone4j.KeystonePreconditions.java
public static void requireAttribute(String attr, String value) { if (Strings.isNullOrEmpty(value)) { String message = MessageFormat.format(REQUIRE_ATTRIBUTE, attr); throw new ValidationException(message, null); }//from w w w .j ava 2 s . c o m }
From source file:com.cinchapi.concourse.util.ObjectUtils.java
/** * Return {@code true} if {@code value} is {@code null} or considered empty. * A value is considered empty if://from w ww . j a v a 2 s. co m * <ul> * <li>It is a collection with no members</li> * <li>It is an array with a length of 0</li> * <li>It is a string with no characters</li> * </ul> * * @param value * @return {@code true} if the object is considered null or empty */ public static boolean isNullOrEmpty(Object value) { return value == null || (value instanceof Collection && ((Collection<?>) value).isEmpty()) || (value.getClass().isArray() && ((Object[]) value).length == 0) || (value instanceof String && Strings.isNullOrEmpty((String) value)); }