List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:com.netflix.spinnaker.halyard.config.validate.v1.security.FileRoleProviderValidator.java
@Override public void validate(ConfigProblemSetBuilder p, FileRoleProvider provider) { if (StringUtils.isEmpty(provider.getPath())) { p.addProblem(Problem.Severity.ERROR, "No permission file path specified."); }/*from ww w. j ava 2 s . co m*/ }
From source file:com.willwinder.universalgcodesender.utils.GUIHelpers.java
/** * Displays an error message to the user. * @param errorMessage message to display in the dialog. * @param modal toggle whether the message should block or fire and forget. *//* w w w .j av a2 s. c om*/ public static void displayErrorDialog(final String errorMessage, boolean modal) { if (StringUtils.isEmpty(errorMessage)) { LOGGER.warning("Something tried to display an error message with an empty message: " + ExceptionUtils.getStackTrace(new Throwable())); return; } Runnable r = () -> { //JOptionPane.showMessageDialog(new JFrame(), errorMessage, // Localization.getString("error"), JOptionPane.ERROR_MESSAGE); NarrowOptionPane.showNarrowDialog(250, errorMessage.replaceAll("\\.\\.", "\\."), Localization.getString("error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); }; if (modal) { r.run(); } else { java.awt.EventQueue.invokeLater(r); } }
From source file:de.hasait.genesis.base.util.GenesisUtils.java
public static String camelCaseToUpperUnderscore(final String pInput) { if (StringUtils.isEmpty(pInput)) { return pInput; }/*from w w w . j av a 2 s. c om*/ final Pattern camelPattern = Pattern.compile("\\p{Lower}\\p{Upper}"); final Matcher camelMatcher = camelPattern.matcher(pInput); final StringBuilder result = new StringBuilder(); int current = 0; while (camelMatcher.find(current)) { final int split = camelMatcher.start() + 1; result.append(pInput.substring(current, split).toUpperCase()); result.append('_'); current = split; } result.append(pInput.substring(current).toUpperCase()); return result.toString(); }
From source file:de.dominikschadow.javasecurity.csrf.CSRFTokenHandler.java
public static String getToken(HttpSession session) throws ServletException, NoSuchAlgorithmException, NoSuchProviderException { if (session == null) { throw new ServletException(MISSING_SESSION); }/*from ww w .java 2 s .co m*/ String token = (String) session.getAttribute(CSRF_TOKEN); if (StringUtils.isEmpty(token)) { token = getToken(); session.setAttribute(CSRF_TOKEN, token); } return token; }
From source file:alpine.util.UuidUtil.java
/** * Determines if the specified string is a valid UUID. * @param uuid the UUID to evaluate// ww w. j a v a 2 s .c o m * @return true if UUID is valid, false if invalid * @since 1.0.0 */ public static boolean isValidUUID(String uuid) { return !StringUtils.isEmpty(uuid) && UUID_PATTERN.matcher(uuid).matches(); }
From source file:com.assignmentone.handler.FormValidateHandler.java
@RequestHandler public Object complete(String name, String age, String bloodtype) { String nameErrMsg = null;// ww w . jav a2s . co m String ageErrMsg = null; if (StringUtils.isEmpty(name)) { nameErrMsg = "name is required."; } if (StringUtils.isEmpty(age)) { ageErrMsg = "age is required."; } else { try { Integer.valueOf(age); } catch (NumberFormatException e) { ageErrMsg = "age must be numeric value."; } } if (nameErrMsg == null && ageErrMsg == null) { return "/templates/form/confirm.html"; } else { Map<String, Object> flashScopeData = new HashMap<>(); flashScopeData.put("name", name); flashScopeData.put("age", age); flashScopeData.put("bloodtype", bloodtype); flashScopeData.put("nameErrMsg", nameErrMsg); flashScopeData.put("ageErrMsg", ageErrMsg); return new RedirectTargetProvider("/app/form/input", flashScopeData); } }
From source file:de.micromata.genome.util.matcher.string.StringEmptyMatcher.java
@Override public boolean matchString(String token) { return StringUtils.isEmpty(token); }
From source file:com.webbfontaine.valuewebb.model.validators.HSCValidator.java
@Override public boolean isValid(Object value) { String hsCode = (String) value; boolean isValid = false; if (StringUtils.isEmpty(hsCode)) { isValid = true;// w w w . j a va 2s . com } else { HSCFinder hscFinder = new HSCFinder(hsCode); if (invalids != null && Arrays.asList(invalids).contains(hsCode)) { isValid = false; } else { if (hsCode.length() == 10) { isValid = !hscFinder.findAll().isEmpty(); } else { if (FacesContext.getCurrentInstance() != null && ((String) Component.getInstance("currentPage", ScopeType.PAGE, true)) .contains("MarketResearch")) { isValid = checkHSCodeForMP(hsCode); } } } } return isValid; }
From source file:monasca.log.api.app.unload.JsonPayloadTransformer.java
@Override public Log transform(final String from) { if (StringUtils.isEmpty(from)) { return new Log().setMessage(""); }// w w w . j ava2 s . com return this.serializer.logFromJson(from.getBytes()); }
From source file:com.thoughtworks.go.validation.PipelineGroupValidator.java
public ValidationBean validate(String pipelineGroupName) { if (StringUtils.isEmpty(pipelineGroupName)) { return ValidationBean.valid(); }/*from w w w . j a v a 2 s. c o m*/ boolean valid = pipelineGroupName.matches(NAME_PATTERN); return valid ? ValidationBean.valid() : ValidationBean.notValid(ERRORR_MESSAGE); }