List of usage examples for org.apache.commons.lang3 StringUtils isNotBlank
public static boolean isNotBlank(final CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true
From source file:com.labs64.netlicensing.domain.vo.Money.java
public static Money convertPrice(final String rawPrice, final String rawCurrency) { final Money target = new Money(); if (StringUtils.isNotBlank(rawPrice)) { try {//ww w. j av a2s .com target.setAmount(DatatypeConverter.parseDecimal(rawPrice)); } catch (final NumberFormatException e) { throw new IllegalArgumentException( "'" + Constants.PRICE + "' format is not correct, expected '0.00' format"); } if (StringUtils.isNotBlank(rawCurrency)) { if (Currency.parseValueSafe(rawCurrency) == null) { throw new IllegalArgumentException("Unsupported currency!"); } target.setCurrencyCode(rawCurrency); } else { throw new IllegalArgumentException("'" + Constants.PRICE + "' field must be accompanied with the '" + Constants.CURRENCY + "' field"); } } else { // 'price' is not provided if (StringUtils.isNotBlank(rawCurrency)) { throw new IllegalArgumentException("'" + Constants.CURRENCY + "' field can not be used without the '" + Constants.PRICE + "' field"); } } return target; }
From source file:cop.raml.utils.javadoc.tags.TagLink.java
public static TagLink create(String className, String param) { className = StringUtils.isNotBlank(className) ? className : null; param = StringUtils.isNotBlank(param) ? param : null; return className != null || param != null ? new TagLink(className, param) : NULL; }
From source file:com.jim.im.utils.ImParamExceptionAssert.java
public static void isNotBlank(CharSequence text, String message) throws ImParamException { if (!StringUtils.isNotBlank(text)) { throwException(message);/*from w ww. j a v a 2s . co m*/ } }
From source file:com.msopentech.odatajclient.engine.communication.request.retrieve.ODataRetrieveRequestFactory.java
/** * Gets a service document request instance. * * @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the * data service./*from ww w. j a v a2 s. co m*/ * @return new ODataServiceDocumentRequest instance. */ public static ODataServiceDocumentRequest getServiceDocumentRequest(final String serviceRoot) { return new ODataServiceDocumentRequest(StringUtils.isNotBlank(serviceRoot) && serviceRoot.endsWith("/") ? new ODataURIBuilder(serviceRoot).build() : new ODataURIBuilder(serviceRoot + "/").build()); }
From source file:com.moviejukebox.model.enumerations.CodecSource.java
/** * Convert a string into an Enum type/*from w w w . ja v a 2 s . c om*/ * * @param source * @return * @throws IllegalArgumentException If type is not recognised * */ public static CodecSource fromString(String source) { if (StringUtils.isNotBlank(source)) { try { return CodecSource.valueOf(source.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("CodecSource " + source + " does not exist.", ex); } } throw new IllegalArgumentException("CodecSource must not be null"); }
From source file:com.dtstack.jlogstash.distributed.util.RouteUtil.java
public static void setHashKey(String hashKey) { RouteUtil.hashKey = hashKey;/*w w w. ja va2 s . co m*/ if (StringUtils.isNotBlank(RouteUtil.hashKey)) { String[] hs = hashKey.split(":"); keyPrefix = hs[0]; keyHashCode = hs[1]; } }
From source file:com.omertron.themoviedbapi.enumeration.MovieMethod.java
/** * Convert a string into an Enum type/*from www. j a v a 2s.com*/ * * @param method * @return * @throws IllegalArgumentException If type is not recognised * */ public static MovieMethod fromString(String method) { if (StringUtils.isNotBlank(method)) { try { return MovieMethod.valueOf(method.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Method " + method + " does not exist.", ex); } } throw new IllegalArgumentException("Method must not be null"); }
From source file:com.thinkgem.jeesite.modules.ip.util.JldwDictUtils.java
/** * ????? ID//from ww w .j a v a2 s .com * @Title: getJldwDictValue * @Description: TODO * @param jldwmc * @param defaultLabel * @return * @return: String */ public static String getJldwDictValue(String jldwmc, String defaultLabel) { if (StringUtils.isNotBlank(jldwmc)) { for (Jldw jldw : getJldwDictList()) { if (jldwmc.equals(jldw.getJldwmc())) { return jldw.getId(); } } } return defaultLabel; }
From source file:com.github.ithildir.airbot.service.MeasurementService.java
public static String getAddress(String country) { String address = MeasurementService.class.getName(); if (StringUtils.isNotBlank(country)) { address += "." + country; }//from w w w. ja v a 2s . c o m return address; }
From source file:com.mirth.connect.util.CodeTemplateUtil.java
public static CodeTemplateDocumentation getDocumentation(String code) { String description = null;//from w w w.j a v a2s . co m CodeTemplateFunctionDefinition functionDefinition = null; if (StringUtils.isNotBlank(code)) { try { FunctionVisitor visitor = new FunctionVisitor(); CompilerEnvirons env = new CompilerEnvirons(); env.setRecordingLocalJsDocComments(true); env.setAllowSharpComments(true); env.setRecordingComments(true); new Parser(env).parse(new StringReader(code), null, 1).visitAll(visitor); description = visitor.getDescription(); functionDefinition = visitor.getFunctionDefinition(); } catch (Exception e) { Matcher matcher = COMMENT_PATTERN.matcher(code); if (matcher.find()) { description = matcher.group().replaceAll("^\\s*/\\*+\\s*|\\s*\\*+/\\s*$", "").trim(); } } } return new CodeTemplateDocumentation(description, functionDefinition); }