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.nike.cerberus.validation.UniqueOwnerValidator.java
public boolean isValid(SafeDepositBox safeDepositBox, ConstraintValidatorContext context) { if (StringUtils.isBlank(safeDepositBox.getOwner()) || safeDepositBox.getUserGroupPermissions() == null || safeDepositBox.getUserGroupPermissions().isEmpty()) { return true; }// ww w . j a va 2s . c o m final Set<String> userGroupNameSet = new HashSet<>(); for (UserGroupPermission userGroupPermission : safeDepositBox.getUserGroupPermissions()) { userGroupNameSet.add(userGroupPermission.getName()); } return !userGroupNameSet.contains(safeDepositBox.getOwner()); }
From source file:com.github.britter.beanvalidators.strings.AlphaNumericConstraintValidator.java
@Override public boolean isValid(final String value, final ConstraintValidatorContext context) { // Don't validate null, empty and blank strings, since these are validated by @NotNull, @NotEmpty and @NotBlank return StringUtils.isBlank(value) || allowSpaces ? StringUtils.isAlphanumericSpace(value) : StringUtils.isAlphanumeric(value); }
From source file:alluxio.security.authorization.ModeParser.java
/** * Parses the given value as a mode.//from w w w.ja va 2s . co m * @param value Value * @return Mode */ public Mode parse(String value) { if (StringUtils.isBlank(value)) { throw new IllegalArgumentException(ExceptionMessage.INVALID_MODE.getMessage(value)); } try { return parseNumeric(value); } catch (NumberFormatException e) { // Treat as symbolic return parseSymbolic(value); } }
From source file:com.threewks.thundr.view.jsonp.JsonpView.java
private void applyDefaults() { if (StringUtils.isBlank(getContentType())) { withContentType(MimeTypes.MIME_APPLICATION_JAVASCRIPT); }//from w w w.j a va 2s .c om if (StringUtils.isBlank(getCharacterEncoding())) { withCharacterEncoding(StringPool.UTF_8); } if (getStatusCode() == null) { withStatusCode(HttpServletResponse.SC_OK); } }
From source file:com.tdclighthouse.prototype.utils.TdcUtils.java
public static String getContextPath(HstRequest request) { String contextPath = request.getRequestContext().getVirtualHost().getVirtualHosts().getDefaultContextPath(); boolean contextPathInUrl = request.getRequestContext().getResolvedMount().getMount().isContextPathInUrl(); if (StringUtils.isBlank(contextPath)) { contextPath = request.getContextPath(); }//w w w .j a v a2 s .c o m return contextPathInUrl ? contextPath : ""; }
From source file:de.micromata.tpsb.doc.parser.japa.handler.AddCommentMethodCallHandler.java
@Override public void handle(MethodCallExpr node, ParserContext ctx) { List<Expression> methodArgs = node.getArgs(); if (methodArgs == null || methodArgs.size() != 1) { return;//from w w w . java 2s .co m } String comment = methodArgs.iterator().next().toString(); if (StringUtils.isBlank(comment) == true) { return; } if (comment.startsWith(QUOTE) == true) { comment = StringUtils.removeStart(comment, QUOTE); } if (comment.endsWith(QUOTE) == true) { comment = StringUtils.removeEnd(comment, QUOTE); } ctx.setCurrentInlineComment(comment); }
From source file:controllers.user.OAuthApp.java
/** * ?// w ww. j a v a 2 s. c o m */ public static Result requestAuth(String provider, String referer, String type) { ClientType clientType = MobileUtil.isMobileUrlPrefix(request().path()) ? ClientType.MOBILE : ClientType.WEB; if (StringUtils.isBlank(referer)) { referer = "/"; } try { if (!OAuth2Service.checkProviderName(provider) || !ProviderType.validateType(provider, type)) { return getResult(ResultType.ILLEGAL_PARAM, clientType, referer); } if (ProviderType.isNeedLogin(type) && !UserAuthService.isLogin(session())) { return getResult(ResultType.NOT_LOGIN, clientType, referer); } OAuthRequestInfo authRequestInfo = new OAuthRequestInfo(); authRequestInfo.setReferer(referer); authRequestInfo.setClientType(clientType); authRequestInfo.setType(type); String specialParamKey = null; if (ClientType.MOBILE == clientType) { authRequestInfo.setFrom(MobileUtil.getFromByUrl(request().path())); specialParamKey = "mobileDisplay"; } else { authRequestInfo.setFrom("web"); } return redirect( OAuth2Service.getRequestAuthURI(provider, type, authRequestInfo.toMap(), specialParamKey)); } catch (Exception e) { LOGGER.error("fail to requestAuth.", e); return getResult(ResultType.AUTH_FAIL, clientType, referer); } }
From source file:io.cloudslang.content.utils.NumberUtilities.java
/** * Given a long integer string, it checks if it's a valid long integer (based on apaches NumberUtils.createLong) * * @param longStr the long integer string to check * @return true if it's valid, otherwise false */// w ww. j av a 2 s.c o m public static boolean isValidLong(@Nullable final String longStr) { if (StringUtils.isBlank(longStr)) { return false; } final String stripedLong = StringUtils.strip(longStr); try { NumberUtils.createLong(stripedLong); return true; } catch (NumberFormatException e) { return false; } }
From source file:com.netsteadfast.greenstep.action.utils.EmailFieldCheckUtils.java
@Override public boolean check(String value) throws ControllerException { if (StringUtils.isBlank(value)) { return true; }/*from w w w.j a v a 2 s . c om*/ String tmp[] = value.split(Constants.ID_DELIMITER); if (tmp == null || tmp.length < 1) { return true; } //EmailValidator emailValidator = EmailValidator.getInstance(); boolean f = true; for (int i = 0; f && i < tmp.length; i++) { //f = emailValidator.isValid(tmp[i]); f = (!tmp[i].endsWith("@") && (tmp[i].indexOf("@") > 0)); } return f; }
From source file:com.adguard.commons.utils.ReservedDomains.java
/** * Initializes/* w w w . j a va2 s.co m*/ */ private static synchronized void initialize() { try { if (reservedDomainNames != null) { // Double check return; } LOG.info("Initialize ReservedDomains object"); InputStream inputStream = ReservedDomains.class.getResourceAsStream("/effective_tld_names.dat"); InputStreamReader reader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(reader); List<String> domains = new ArrayList<>(); String line; while ((line = bufferedReader.readLine()) != null) { line = line.trim(); if (!StringUtils.isBlank(line)) { domains.add(line); } } reservedDomainNames = new String[domains.size()]; domains.toArray(reservedDomainNames); Arrays.sort(reservedDomainNames); LOG.info("ReservedDomains object has been initialized"); } catch (Exception ex) { throw new RuntimeException("Cannot initialize reserved domains collection", ex); } }