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.esri.geoevent.test.performance.RequestType.java
public static RequestType fromValue(String valueStr) { if (StringUtils.isBlank(valueStr)) return UNKNOWN; else if (INIT.toString().equalsIgnoreCase(valueStr)) return INIT; else if (VALIDATE.toString().equalsIgnoreCase(valueStr)) return VALIDATE; else if (START.toString().equalsIgnoreCase(valueStr)) return START; else if (STOP.toString().equalsIgnoreCase(valueStr)) return STOP; else if (RESET.toString().equalsIgnoreCase(valueStr)) return RESET; else if (RESET.toString().equalsIgnoreCase(valueStr)) return RESET; else if (DESTROY.toString().equalsIgnoreCase(valueStr)) return DESTROY; else if (IS_RUNNING.toString().equalsIgnoreCase(valueStr)) return IS_RUNNING; else if (GET_RUNNING_STATE.toString().equalsIgnoreCase(valueStr)) return GET_RUNNING_STATE; else if (GET_TIMESTAMPS.toString().equalsIgnoreCase(valueStr)) return GET_TIMESTAMPS; else if (GET_NUMBER_OF_EVENTS.toString().equalsIgnoreCase(valueStr)) return GET_NUMBER_OF_EVENTS; else if (SET_NUMBER_OF_EVENTS.toString().equalsIgnoreCase(valueStr)) return SET_NUMBER_OF_EVENTS; else if (SET_NUMBER_OF_EXPECTED_RESULTS.toString().equalsIgnoreCase(valueStr)) return SET_NUMBER_OF_EXPECTED_RESULTS; else if (GET_SUCCESSFUL_EVENTS.toString().equalsIgnoreCase(valueStr)) return GET_SUCCESSFUL_EVENTS; else if (GET_SUCCESSFUL_EVENT_BYTES.toString().equalsIgnoreCase(valueStr)) return GET_SUCCESSFUL_EVENT_BYTES; else//from w ww.j av a 2 s .c om return UNKNOWN; }
From source file:com.cognifide.aet.job.api.ParametersValidator.java
public static void checkNotBlank(String value, String errorMessage) throws ParametersException { if (StringUtils.isBlank(value)) { throw new ParametersException(errorMessage); }/*from ww w.ja v a 2 s . c o m*/ }
From source file:com.withub.common.SearchFilter.java
/** * searchParamskey?OPERATOR_FIELDNAME//from ww w. j a v a2 s. co m */ public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) { Map<String, SearchFilter> filters = Maps.newHashMap(); for (Map.Entry<String, Object> entry : searchParams.entrySet()) { // String key = entry.getKey(); Object value = entry.getValue(); if (value == null || StringUtils.isBlank(value.toString())) { continue; } // operatorfiledAttribute String[] names = StringUtils.split(key, "_"); if (names.length != 2) { throw new IllegalArgumentException(key + " is not a valid search filter name"); } String filedName = names[1]; Operator operator = Operator.valueOf(names[0]); // searchFilter SearchFilter filter = new SearchFilter(filedName, operator, value); filters.put(key, filter); } return filters; }
From source file:com.smartling.cms.gateway.client.api.model.Status.java
public static Status findByName(String statusName) { if (StringUtils.isBlank(statusName)) { return null; }/*from w ww .ja v a 2s . c o m*/ for (Status status : values()) { if (status.name().equals(statusName)) { return status; } } return null; }
From source file:com.manisha.allmybooksarepacked.utility.JSONUtils.java
@SuppressWarnings("unchecked") public static <T> T JSONToObject(String json, Class<T> clazz) throws IOException { if (clazz == null || clazz.isAssignableFrom(String.class)) return (T) json; if (StringUtils.isBlank(json)) return null; return mapper.readValue(StringEscapeUtils.unescapeJson(json), clazz); }
From source file:com.thinkbiganalytics.jobrepo.rest.controller.QueryUtils.java
/** * This will evaluate the {@code incomingFilter} and append/set the value including the {@code defaultFilter} and return a new String with the updated filter *//*ww w . ja va2 s. c o m*/ public static String ensureDefaultFilter(String incomingFilter, String defaultFilter) { String filter = incomingFilter; if (StringUtils.isBlank(filter) || !StringUtils.containsIgnoreCase(filter, defaultFilter)) { if (StringUtils.isNotBlank(filter)) { if (StringUtils.endsWith(filter, ",")) { filter += defaultFilter; } else { filter += "," + defaultFilter; } } else { filter = defaultFilter; } } return filter; }
From source file:com.ciwen.xhb.cms.common.persistence.SearchFilter.java
/** * searchParamskey?OPERATOR_FIELDNAME//from w w w. j a va2s . c o m */ public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) { Map<String, SearchFilter> filters = Maps.newHashMap(); for (Entry<String, Object> entry : searchParams.entrySet()) { // String key = entry.getKey(); Object value = entry.getValue(); if (StringUtils.isBlank(String.valueOf(value))) { continue; } // operatorfiledAttribute String[] names = StringUtils.split(key, "_"); if (names.length != 2) { throw new IllegalArgumentException(key + " is not a valid search filter name"); } String filedName = names[1]; Operator operator = Operator.valueOf(names[0]); // searchFilter SearchFilter filter = new SearchFilter(filedName, operator, value); filters.put(key, filter); } return filters; }
From source file:mobile.service.core.ClientLogService.java
/** * //from ww w .j av a 2 s . co m * * @param from ??, * @param sourceFile length>0 * @param description ??,? */ public static void uploadLog(final String from, File sourceFile, final String description) { if (sourceFile == null || StringUtils.isBlank(from)) { throw new IllegalArgumentException("illegal param. sourceFile = " + sourceFile + ", from = " + from); } if (sourceFile.length() <= 0) { throw new IllegalArgumentException("sourceFile.length() <= 0"); } String absDestFilePath = JPAUtil.indieTransaction(new IndieTransactionFunc<String>() { @Override public String call(EntityManager em) { // ? DateTime now = new DateTime(); MobileClientLog log = new MobileClientLog(); log.setCreateTime(now.toDate()); log.setDescription(description); log.setDevice(from); JPA.em().persist(log); String destFileName = now.toString("yyyyMMdd-HHmmss") + "-" + log.getId() + ".log"; String absDestFilePath = FileService.getMobileAbsUploadPath() + "clientLog/" + destFileName; String relDestFilePath = FileService.getMobileRelUploadPath() + "clientLog/" + destFileName; log.setLogFileUrl(relDestFilePath); JPA.em().merge(log); return absDestFilePath; } }); File destFile = new File(absDestFilePath); if (!destFile.getParentFile().exists()) { destFile.getParentFile().mkdirs(); } FileService.copyFile(sourceFile.getAbsolutePath(), absDestFilePath); }
From source file:com.thoughtworks.go.agent.common.util.HeaderUtil.java
public static Map<String, String> parseExtraProperties(Header extraPropertiesHeader) { if (extraPropertiesHeader == null || StringUtils.isBlank(extraPropertiesHeader.getValue())) { return new HashMap<>(); }/*from www.j av a2 s . c om*/ try { final String headerValue = new String(Base64.decodeBase64(extraPropertiesHeader.getValue()), UTF_8); if (StringUtils.isBlank(headerValue)) { return new HashMap<>(); } return Arrays.stream(headerValue.trim().split(" +")).map(property -> property.split("=")) .collect(Collectors.toMap(keyAndValue -> keyAndValue[0].replaceAll("%20", " "), keyAndValue -> keyAndValue[1].replaceAll("%20", " "), (value1, value2) -> value1, LinkedHashMap::new)); } catch (Exception e) { LOGGER.warn("Failed to parse extra properties header value: {}", extraPropertiesHeader.getValue(), e); return new HashMap<>(); } }
From source file:ca.uhn.fhir.util.ObjectUtil.java
public static void requireNotEmpty(String str, String message) { if (StringUtils.isBlank(str)) { throw new IllegalArgumentException(message); }//ww w .j a v a 2 s.c om }