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.hybris.mobile.app.commerce.utils.ProductUtils.java
/** * Sum up quantities to get total value price and round off to 2 digit * * @param quantity : item quantity added * @param productPrice : price for single item * @return/*w w w.j av a 2s. c o m*/ */ public static String calculateQuantityPrice(String quantity, Price productPrice) { String total = "00.00"; try { if (StringUtils.isNotBlank(quantity) && Integer.parseInt(quantity) > 0 && productPrice != null) { total = String.valueOf(Constants.PRICE_SMALL .format((Integer.parseInt(quantity) * productPrice.getValue().doubleValue()))); } } catch (NumberFormatException e) { Log.e(TAG, e.getLocalizedMessage()); } return total; }
From source file:com.omertron.bgg.enums.PrimaryAlternative.java
/** * Convert a string into an Enum type//from w ww.j a v a 2 s . com * * @param source String representation of the enum to convert * @return The enum that matches the source * @throws IllegalArgumentException If type is not recognised */ public static PrimaryAlternative fromString(String source) { if (StringUtils.isNotBlank(source)) { try { return PrimaryAlternative.valueOf(source.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("PrimaryAlternative " + source + " does not exist.", ex); } } throw new IllegalArgumentException("PrimaryAlternative must not be null"); }
From source file:com.omertron.bgg.enums.FamilyType.java
/** * Convert a string into an Enum type/*from w w w . ja va2 s .com*/ * * @param source String representation of the enum to convert * @return The enum that matches the source * @throws IllegalArgumentException If type is not recognised */ public static FamilyType fromString(String source) { if (StringUtils.isNotBlank(source)) { try { return FamilyType.valueOf(source.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("FamilyType " + source + " does not exist.", ex); } } throw new IllegalArgumentException("FamilyType must not be null"); }
From source file:com.mirth.connect.util.ErrorMessageBuilder.java
public static String buildErrorMessage(String errorType, String customMessage, Throwable e) { String errorSourceLine = null; // if the exception occurred during execution of the script, get the // line of code that caused the error if (e instanceof RhinoException) { errorSourceLine = ((RhinoException) e).lineSource(); }// w w w .j a v a2s. c o m // construct the error message StringBuilder builder = new StringBuilder(); String stackTrace = new String(); if (e != null) { stackTrace = ExceptionUtils.getStackTrace(e); } builder.append(errorType); builder.append(" error"); if (StringUtils.isNotBlank(errorSourceLine)) { builder.append(LINE_SEPARATOR); builder.append("ERROR SOURCE: "); builder.append(errorSourceLine); } if (StringUtils.isNotBlank(customMessage)) { builder.append(LINE_SEPARATOR); builder.append("ERROR MESSAGE: "); builder.append(customMessage); } if (StringUtils.isNotBlank(stackTrace)) { builder.append(LINE_SEPARATOR); builder.append(stackTrace); } return builder.toString(); }
From source file:com.ejisto.util.ContainerUtils.java
public static String extractAgentJar(String classPath) { String systemProperty = System.getProperty("ejisto.agent.jar.path"); if (StringUtils.isNotBlank(systemProperty)) { return systemProperty; }//from w w w. jav a 2s . c o m final Optional<String> agentPath = Arrays.stream(classPath.split(Pattern.quote(File.pathSeparator))) .filter(e -> AGENT_JAR.matcher(e).matches()).findFirst(); if (agentPath.isPresent()) { return Paths.get(System.getProperty("user.dir"), agentPath.get()).toString(); } throw new IllegalStateException("unable to find agent jar"); }
From source file:com.moviejukebox.model.enumerations.CodecType.java
/** * Convert a string into an Enum type/*from ww w . ja v a 2 s . c o m*/ * * @param type * @return * @throws IllegalArgumentException If type is not recognised * */ public static CodecType fromString(String type) { if (StringUtils.isNotBlank(type)) { try { return CodecType.valueOf(type.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("CodecType " + type + " does not exist.", ex); } } throw new IllegalArgumentException("CodecType must not be null"); }
From source file:com.moviejukebox.model.attachment.AttachmentType.java
/** * Convert a string into an Enum type//from w ww .ja v a 2 s.co m * * @param type * @return * @throws IllegalArgumentException If type is not recognised * */ public static AttachmentType fromString(String type) { if (StringUtils.isNotBlank(type)) { try { return AttachmentType.valueOf(type.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("AttachmentType " + type + " does not exist.", ex); } } throw new IllegalArgumentException("AttachmentType must not be null"); }
From source file:com.ufukuzun.myth.dialect.util.ExpressionUtils.java
public static List<String> splitIdFragments(String value) { List<String> idFragments = new ArrayList<String>(); if (StringUtils.isNotBlank(value)) { value = StringUtils.remove(value, "${}"); Matcher matcher = DOLLAR_EXPRESSION_PATTERN.matcher(value); while (matcher.find()) { idFragments.add(matcher.group()); value = StringUtils.remove(value, matcher.group()); }/* w w w . j a va 2s . com*/ idFragments.addAll(Arrays.asList(StringUtils.split(value))); } return idFragments; }
From source file:com.yevster.spdxtra.Validate.java
public static void spdxElementId(String spdxId) { boolean valid = StringUtils.isNotBlank(spdxId) && !StringUtils.containsAny(spdxId, '#', ':') && StringUtils.startsWith(spdxId, "SPDXRef-"); if (!valid)/*from w w w .ja va 2s .c om*/ throw exceptionFactory.apply(spdxId + " is not a valid SPDX Element ID."); }
From source file:controllers.api.v1.User.java
public static Result updateSettings() { Map<String, String[]> params = request().body().asFormUrlEncoded(); ObjectNode result = Json.newObject(); String username = session("user"); if (StringUtils.isNotBlank(username)) { String message = UserDAO.updateUserSettings(params, username); if (StringUtils.isBlank(message)) { result.put("status", "success"); } else {/*from w ww . jav a2 s . c o m*/ result.put("status", "failed"); result.put("message", message); } } else { result.put("status", "failed"); result.put("message", "User is not authenticated"); } return ok(result); }