List of usage examples for org.apache.commons.lang StringUtils isNotBlank
public static boolean isNotBlank(String str)
Checks if a String is not empty (""), not null and not whitespace only.
From source file:com.iorga.webappwatcher.util.PatternListParameterHandler.java
@Override protected List<Pattern> convertFromString(final String value) { final List<Pattern> patterns = new ArrayList<Pattern>(); final String[] includes = value.split(","); for (final String include : includes) { if (StringUtils.isNotBlank(include)) { patterns.add(Pattern.compile(include)); }/* w w w . j a v a 2 s. co m*/ } return patterns; }
From source file:com.zxy.commons.memcache.MemcachePropUtils.java
/** * ???// w w w. j ava 2 s .c o m * * @return ?? */ public static List<Integer> getWeights() { String weights = getInstance().getString("weights"); if (StringUtils.isNotBlank(weights)) { List<Integer> weightsList = new ArrayList<Integer>(); String[] weightsArray = weights.split("[\\s\\,]"); for (String w : weightsArray) { weightsList.add(Integer.parseInt(w)); } return weightsList; } return null; }
From source file:net.sf.click.jquery.examples.services.CustomerService.java
@SuppressWarnings("unchecked") public List<Customer> getCustomersForPage(int offset, int pageSize, final String sortColumn, final boolean ascending) { // Ok this implementation is a cheat since all customers are in memory List<Customer> customers = StartupListener.CUSTOMERS; if (StringUtils.isNotBlank(sortColumn)) { Collections.sort(customers, new Comparator() { public int compare(Object o1, Object o2) { int ascendingSort = ascending ? 1 : -1; Comparable v1 = (Comparable) PropertyUtils.getValue(o1, sortColumn); Comparable v2 = (Comparable) PropertyUtils.getValue(o2, sortColumn); if (v1 == null) { return -1 * ascendingSort; } else if (v2 == null) { return 1 * ascendingSort; }//from w w w.j a v a 2 s . c om return v1.compareTo(v2) * ascendingSort; } }); } return customers.subList(offset, Math.min(offset + pageSize, customers.size())); }
From source file:de.tsystems.mms.apm.performancesignature.dynatrace.rest.TestRunDetailsXMLHandler.java
public TestRun getParsedObjects() throws RESTErrorException { if (StringUtils.isNotBlank(errorMsg)) { throw new RESTErrorException(errorMsg); }/*ww w . ja v a 2s. c o m*/ return this.testRun; }
From source file:com.baidu.terminator.manager.service.LinkServiceImpl.java
@Override public List<Link> getLinkByName(String name) { if (StringUtils.isNotBlank(name)) { return linkMapper.selectLinkByName("%" + name + "%"); } else {/* www.j av a 2s . c o m*/ return getAllLink(); } }
From source file:com.googlecode.markuputils.MarkupUtils.java
public static String closeElement(String name) { StringBuilder buffer = new StringBuilder(); if (StringUtils.isNotBlank(name)) { buffer.append("</").append(name).append(">"); }/*from w ww . j a v a 2 s.c o m*/ return buffer.toString(); }
From source file:me.philnate.textmanager.updates.Updater.java
/** * checks what the actual db version is, if an old version is encountered * appropriate updates are performed to get the db to the latest version *//* w ww.j av a2s .c om*/ public static void checkUpdateNeeded(String packageName) { checkArgument(StringUtils.isNotBlank(packageName), "You must insert a packageName"); TreeMap<Version, Class<? extends Update>> updates = createUpdateList(packageName); Setting v = Setting.find("version"); // check that an version is set, if none was found set it to 1 LOG.info(format("Database version is %s", v.getValue())); if (StringUtils.isBlank(v.getValue())) { Version db = (Version) ComparatorUtils.min(startVersion, updates.lastKey(), null); LOG.debug(String.format("No Version set, assuming []", db.toString())); v = new Setting("version", db); ds.save(v); } LOG.info(format("Found these Database upgrades: '%s'", updates.keySet())); for (Version vers : updates.keySet()) { if (vers.compareTo(new Version(v.getValue())) < Version.AFTER) { // if version is smaller than actual db version we have nothing // todo here LOG.debug(format("Database is already newer than '%s'", vers)); continue; } try { LOG.info(format("Going to update Database to version '%s'", vers)); backUp(); // create new Instance Update up = updates.get(vers).newInstance(); // verify that everything is met for this update up.preCheck(); // do the actual update up.upgrade(); // verify that everything is as expected up.postCheck(); // update the version v.setValue(vers.toString()).save(); } catch (Exception e) { // in case of an exception stop further rollback and stop // further updates LOG.error("Update process caused an exception going to rollback", e); rollback(); return; } finally { // finally drop backup directory to avoid to get conflicting // data versions try { FileUtils.deleteDirectory(backUpPath); } catch (IOException e) { LOG.error("Could not remove file", e); } } } }
From source file:com.acc.validator.CCPaymentInfoValidator.java
@Override public void validate(final Object target, final Errors errors) { final CCPaymentInfoData ccPaymentData = (CCPaymentInfoData) target; if (StringUtils.isNotBlank(ccPaymentData.getStartMonth()) && StringUtils.isNotBlank(ccPaymentData.getStartYear()) && StringUtils.isNotBlank(ccPaymentData.getExpiryMonth()) && StringUtils.isNotBlank(ccPaymentData.getExpiryYear())) { final Calendar start = Calendar.getInstance(); start.set(Calendar.DAY_OF_MONTH, 0); start.set(Calendar.MONTH, Integer.parseInt(ccPaymentData.getStartMonth()) - 1); start.set(Calendar.YEAR, Integer.parseInt(ccPaymentData.getStartYear()) - 1); final Calendar expiration = Calendar.getInstance(); expiration.set(Calendar.DAY_OF_MONTH, 0); expiration.set(Calendar.MONTH, Integer.parseInt(ccPaymentData.getExpiryMonth()) - 1); expiration.set(Calendar.YEAR, Integer.parseInt(ccPaymentData.getExpiryYear()) - 1); if (start.after(expiration)) { errors.rejectValue("startMonth", "payment.startDate.invalid"); }//w w w . j ava 2 s . c om } ValidationUtils.rejectIfEmptyOrWhitespace(errors, "accountHolderName", "field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cardType", "field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cardNumber", "field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "expiryMonth", "field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "expiryYear", "field.required"); paymentAddressValidator.validate(ccPaymentData, errors); }
From source file:com.betfair.tornjak.monitor.overlay.RegExpMatcher.java
private Pattern createPattern(String regEx) { if (StringUtils.isNotBlank(regEx)) { return Pattern.compile(regEx, Pattern.CASE_INSENSITIVE); }/*from w ww . j av a 2s.c o m*/ return null; }
From source file:com.nagarro.core.validator.FieldEmptyValidator.java
@Override public void validate(final Object object, final Errors errors) { Assert.notNull(errors, "Errors object must not be null"); final Object fieldValue = errors.getFieldValue(fieldPath); if (fieldValue != null && (fieldValue instanceof String && StringUtils.isNotBlank((String) fieldValue))) { errors.rejectValue(fieldPath, FIELD_REQUIRED_MESSAGE_ID, new String[] { fieldPath }, null); }// w w w.ja v a2 s.c o m }