Example usage for org.apache.commons.lang3 StringUtils isBlank

List of usage examples for org.apache.commons.lang3 StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isBlank.

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

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 

Usage

From source file:com.erudika.para.persistence.PersistenceModule.java

protected void configure() {
    String selectedDAO = Config.getConfigParam("database", "");
    if (StringUtils.isBlank(selectedDAO)) {
        if ("embedded".equals(Config.ENVIRONMENT)) {
            bind(DAO.class).to(IndexBasedDAO.class).asEagerSingleton();
        } else {/*  w  ww  . j  a  va2 s.  c om*/
            bind(DAO.class).to(AWSDynamoDAO.class).asEagerSingleton();
        }
    } else {
        if ("elasticsearch".equalsIgnoreCase(selectedDAO)) {
            bind(DAO.class).to(IndexBasedDAO.class).asEagerSingleton();
        } else if ("dynamodb".equalsIgnoreCase(selectedDAO)) {
            bind(DAO.class).to(AWSDynamoDAO.class).asEagerSingleton();
        } else if ("cassandra".equalsIgnoreCase(selectedDAO)) {
            // Cassandra connector plugin
        } else if ("mongodb".equalsIgnoreCase(selectedDAO)) {
            // MongoDB connector plugin
        } else if ("postgre".equalsIgnoreCase(selectedDAO)) {
            // MongoDB connector plugin
        } else {
            // in-memory DB
            bind(DAO.class).to(MockDAO.class).asEagerSingleton();
        }
    }
}

From source file:com.github.britter.beanvalidators.net.DomainConstraintValidator.java

@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
    return StringUtils.isBlank(value) || DomainValidator.getInstance().isValid(value);
}

From source file:eu.ggnet.dwoss.redtape.ShippingCostHelper.java

/**
 * Method to update/refresh the shipping cost of a {@link Document}.
 * <p>/*from  w w w  . j  a va  2 s  . c o  m*/
 * @param doc               the {@link Document} entity.
 * @param shippingCondition the condition on which the shipping cost is calculated
 */
public static void modifyOrAddShippingCost(Document doc, ShippingCondition shippingCondition) {
    int amountOfPositions = doc.getPositions(PositionType.UNIT).size();
    for (Position position : doc.getPositions(PositionType.PRODUCT_BATCH).values()) {
        //just quick for the warranty extension. sucks a bit if we ever wouldhave a refurbished id on another product batch
        if (!StringUtils.isBlank(position.getRefurbishedId()))
            continue;
        amountOfPositions += position.getAmount();
    }
    double costs = 0;
    if (Client.hasFound(ShippingCostService.class))
        costs = Client.lookup(ShippingCostService.class).calculate(amountOfPositions,
                doc.getDossier().getPaymentMethod(), shippingCondition);
    SortedMap<Integer, Position> positions = doc.getPositions(PositionType.SHIPPING_COST);
    if (positions.isEmpty()) {
        PositionBuilder pb = new PositionBuilder().setType(PositionType.SHIPPING_COST).setName("Versandkosten")
                .setDescription("Versandkosten zu Vorgang: " + doc.getDossier().getIdentifier()).setPrice(costs)
                .setTax(GlobalConfig.TAX).setAfterTaxPrice(costs + (costs * GlobalConfig.TAX))
                .setBookingAccount(Client.lookup(MandatorSupporter.class).loadPostLedger()
                        .get(PositionType.SHIPPING_COST).orElse(-1));
        doc.append(pb.createPosition());
    } else {
        Position next = positions.values().iterator().next();
        next.setPrice(costs);
        next.setAfterTaxPrice(costs + (costs * GlobalConfig.TAX));
    }
}

From source file:comp.web.core.DataUtil.java

public List<Product> getProds(String cat, String prod, String from, String to) {
    logger.log(Level.FINER, "get prods with filter {0} {1} {2} {3}", new Object[] { cat, prod, from, to });

    if (StringUtils.isBlank(cat) && StringUtils.isBlank(prod) && StringUtils.isBlank(from)
            && StringUtils.isBlank(to)) {
        return Collections.emptyList();
    }//  w ww.  ja  va2  s .  c o  m

    String cat1 = StringUtils.stripToEmpty(cat) + "%";
    String prod1 = StringUtils.stripToEmpty(prod) + "%";
    double from1 = StringUtils.isNumeric(from) ? Double.parseDouble(from) : Double.MIN_VALUE;
    double to1 = StringUtils.isNumeric(to) ? Double.parseDouble(to) : Double.MAX_VALUE;

    EntityManager em = createEM();
    //        EntityTransaction tx = em.getTransaction();
    //        tx.begin();

    List<Product> products = em.createNamedQuery("priceList", Product.class).setParameter("cat", cat1)
            .setParameter("prod", prod1).setParameter("from", from1).setParameter("to", to1).getResultList();

    //        tx.commit();
    em.close();
    logger.log(Level.FINER, "get prods result size {0}", products.size());
    return products;
}

From source file:gov.nih.nci.caintegrator.application.analysis.geneexpression.GEPlotClinicalQueryBasedParameters.java

/**
 * {@inheritDoc}/*from  w w  w  .j a v a 2 s  .  c om*/
 */
@Override
public boolean validate() {
    getErrorMessages().clear();
    boolean isValid = true;
    if (isMultiplePlatformsInStudy() && StringUtils.isBlank(getPlatformName())) {
        getErrorMessages().add("Must select a platform");
        isValid = false;
    }
    if (StringUtils.isBlank(getGeneSymbol())) {
        getErrorMessages().add("Must enter a gene symbol");
        isValid = false;
    }
    if (queries.isEmpty()) {
        getErrorMessages().add("Must select at least one query.");
        isValid = false;
    }
    return isValid;
}

From source file:jease.cms.web.content.editor.FolderEditor.java

@Override
protected void doValidate() throws Exception {
    if (StringUtils.isBlank(name.getValue())) {
        //         if(StringUtils.isNotBlank(title.getValue())) {
        //            getNode().setName(title.getValue());
        //         }
    }/*from   w  w  w .j  av  a  2  s.  co  m*/
    super.doValidate();
}

From source file:kenh.expl.functions.IsBlank.java

public boolean process(Object obj) {
    if (obj == null)
        return true;

    if (obj instanceof String) {
        String var = (String) obj;

        return StringUtils.isBlank(var);
    } else {//  www.j  a  v  a  2 s  .  c  o  m
        return false;
    }

}

From source file:br.ufac.sion.converter.OrgaoExpedidorConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if (StringUtils.isBlank(value)) {
        return null;
    }//from   w  w w  . j ava 2s .  c  o m
    return this.orgaoExpedidorFacade.findById(new Long(value));
}

From source file:com.alibaba.event.AbstractEventListener.java

/**
 * //from   w  ww  .j  a v a2 s .com
 * 
 * @param eventContext
 */
public void response(EventContext eventContext) throws EventException {
    if (eventContext == null) {
        return;
    }

    String triggerEventName = eventContext.getEventName();
    if (StringUtils.isBlank(triggerEventName)) {
        return;
    }

    EventDTO eventDTO = eventContext.getEventDTO();
    for (EventModel eventModel : eventList) {
        try {
            String eventName = eventModel.getEventName();
            if (triggerEventName.equals(eventName)) {
                IEventCallBack eventCallBack = eventModel.getEventCallBack();
                if (eventCallBack == null) {
                    throw new EventException(
                            String.format("can't get call back for event=%s", triggerEventName));
                } else {
                    /***************************************************
                     * 
                     ***************************************************/
                    eventCallBack.execute(eventDTO);
                    break;
                }
            }
        } catch (Exception e) {
            throw new EventException(e.getMessage(), e.getCause());
        }
    }
}

From source file:io.jmnarloch.cd.go.plugin.gradle.GradleTaskValidator.java

/**
 * {@inheritDoc}/*  www .  java  2  s .c o m*/
 */
@Override
public void validate(Map<String, Object> properties, ValidationErrors errors) {

    if (StringUtils.isBlank(getProperty(properties, GradleTaskConfig.TASKS.getName()))) {
        errors.addError(GradleTaskConfig.TASKS.getName(), "You need to specify Gradle tasks");
    }
}