List of usage examples for org.apache.commons.lang3 StringUtils isBlank
public static boolean isBlank(final CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
From source file:com.bitplantoon.common.factory.PropFactory.java
public static Map getYMLProperties(String moduleName) { try {/*from ww w . jav a2s . c o m*/ String location = System.getProperty("yaml.properties.directory"); if (StringUtils.isBlank(location)) { //SET DEFAULT LOCATION location = "/tmp/system.8bitplantoon/properties/"; } return (Map) new Yaml() .load(new BufferedReader(new FileReader(new File(location + "/" + moduleName + ".yml")))); } catch (FileNotFoundException ex) { throw new RuntimeException("The YML file for " + moduleName + " was not found, ensure its within you resources/properties forlder"); } }
From source file:com.naver.dynamicprogramming.levenshtein.Levenshtein.java
private static int calculateDistanceRecursive(String str1, String str2, int distance) { if (StringUtils.isBlank(str1) && StringUtils.isBlank(str2)) { return distance; }/* w w w . ja v a2 s . co m*/ if (StringUtils.isBlank(str1)) { return distance + str2.length(); } if (StringUtils.isBlank(str2)) { return distance + str1.length(); } boolean isEqualEndChar = str1.charAt(str1.length() - 1) == str2.charAt(str2.length() - 1); if (isEqualEndChar) { return calculateDistanceRecursive(str1.substring(0, str1.length() - 1), str2.substring(0, str2.length() - 1), distance); } else { int case1 = calculateDistanceRecursive(str1.substring(0, str1.length() - 1), str2.substring(0, str2.length() - 1), distance + 1); int case2 = calculateDistanceRecursive(str1, str2.substring(0, str2.length() - 1), distance + 1); int case3 = calculateDistanceRecursive(str1.substring(0, str1.length() - 1), str2, distance + 1); return NumberUtils.min(case1, case2, case3); } }
From source file:jp.toastkid.script.models.Language.java
/** * ??????./*from w w w . j av a2 s. co m*/ * @param lang * @return ? */ public static String extension(final String lang) { if (StringUtils.isBlank(lang)) { return ".groovy"; } return extension(Language.valueOf(lang.toUpperCase())); }
From source file:com.alibaba.design.patterns.strategy.StrategyEnum.java
public static StrategyEnum typeOf(String value) { if (StringUtils.isBlank(value)) { return null; }//from www. jav a2 s. co m for (StrategyEnum strategy : StrategyEnum.values()) { if (value.equals(strategy.getValue())) { return strategy; } } return null; }
From source file:com.ctrip.infosec.rule.resource.QiAn.java
/** * ip??/*from www.j a v a2s .c om*/ * * @param ip * @param mobile * @return * {"msg":null,"success":1,"mobile":{"score":null,"is_notreal":null},"ip":{"is_proxy":0,"score":50.0,"ip":"218.17.231.209"}} */ public static Map<String, Object> queryRegEvent(String ip, String mobile) { if (StringUtils.isBlank(ip) && StringUtils.isBlank(mobile)) { return Collections.EMPTY_MAP; } Map<String, Object> params = new HashMap<>(); params.put("mobile", mobile); params.put("ip", ip); return DataProxy.queryForMap(serviceName, operationName, params); }
From source file:net.packet.BillingCycle.java
public static BillingCycle fromValue(String value) { if (StringUtils.isBlank(value)) { throw new IllegalArgumentException("Value cannot be null or empty!"); }//from w w w. j a va 2 s. c o m for (BillingCycle bc : BillingCycle.values()) { if (value.equalsIgnoreCase(bc.value)) { return bc; } } throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); }
From source file:fm.pattern.tokamak.authorization.StringTokenizer.java
public static Set<String> tokenize(String input) { return StringUtils.isBlank(input) ? new HashSet<String>() : new HashSet<String>(Arrays.asList(input.trim().split("\\s*,\\s*"))); }
From source file:ch.cyberduck.core.PathRelativizer.java
public static String relativize(String root, final String path) { if (StringUtils.isBlank(root)) { return path; }// w ww.jav a 2 s.c o m if (!StringUtils.equals(root, String.valueOf(Path.DELIMITER))) { root = root + String.valueOf(Path.DELIMITER); } if (StringUtils.contains(path, root)) { return path.substring(path.indexOf(root) + root.length()); } return path; }
From source file:com.alibaba.design.patterns.factory.AnimalEnum.java
/** * /*w w w. j a v a2 s . c o m*/ * * @param value * @return */ public static AnimalEnum typeOf(String value) { if (StringUtils.isBlank(value)) { return null; } for (AnimalEnum animal : AnimalEnum.values()) { if (animal.value.equalsIgnoreCase(value)) { return animal; } } return null; }
From source file:net.packet.TrafficDirection.java
public static TrafficDirection fromValue(String value) { if (StringUtils.isBlank(value)) { throw new IllegalArgumentException("Value cannot be null or empty!"); }/*from w w w . j av a2s.c o m*/ for (TrafficDirection td : TrafficDirection.values()) { if (value.equalsIgnoreCase(td.value)) { return td; } } throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); }