Example usage for org.apache.commons.lang StringUtils isEmpty

List of usage examples for org.apache.commons.lang StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isEmpty.

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:converters.StringToPropertyConverter.java

@Override
public Property convert(String text) {
    Property result;/*from  www.  jav  a  2s .  com*/
    int id;

    try {
        if (StringUtils.isEmpty(text))
            result = null;
        else {
            id = Integer.valueOf(text);
            result = propertyRepository.findOne(id);
        }
    } catch (Throwable oops) {
        throw new IllegalArgumentException(oops);
    }

    return result;
}

From source file:converters.StringToParamRentConverter.java

@Override
public ParamRent convert(String text) {
    ParamRent result;/*from w  w w . j a  v  a 2 s .c o  m*/
    int id;

    try {
        if (StringUtils.isEmpty(text))
            result = null;
        else {
            id = Integer.valueOf(text);
            result = paramRentRepository.findOne(id);
        }
    } catch (Throwable oops) {
        throw new IllegalArgumentException(oops);
    }

    return result;
}

From source file:converters.StringToParamSellConverter.java

@Override
public ParamSell convert(String text) {
    ParamSell result;/*www. j  av a2  s. c  om*/
    int id;

    try {
        if (StringUtils.isEmpty(text))
            result = null;
        else {
            id = Integer.valueOf(text);
            result = paramSellRepository.findOne(id);
        }
    } catch (Throwable oops) {
        throw new IllegalArgumentException(oops);
    }

    return result;
}

From source file:converters.StringToProfessorConverter.java

@Override
public Professor convert(String text) {
    Professor result;/*from w  w w. j a  va  2s . c o m*/
    int id;

    try {
        if (StringUtils.isEmpty(text))
            result = null;
        else {
            id = Integer.valueOf(text);
            result = professorRepository.findOne(id);
        }
    } catch (Throwable oops) {
        throw new IllegalArgumentException(oops);
    }

    return result;
}

From source file:com.devnexus.ting.web.converter.StringToSkillLevel.java

@Override
public SkillLevel convert(String source) {

    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {/* w w  w  . j  a v  a2 s. c  om*/
        return SkillLevel.fromId(Long.valueOf(source));
    }

}

From source file:cz.strmik.cmmitool.util.validator.OrganizationValidator.java

@Override
public void validate(Object target, Errors errors) {
    ValidationUtils.rejectIfEmpty(errors, "name", "field-required");
    Organization org = (Organization) target;
    if (!StringUtils.isEmpty(org.getEmail())) {
        Matcher emailMatcher = PATTERN_EMAIL.matcher(org.getEmail());
        if (!emailMatcher.matches()) {
            errors.rejectValue("email", "invalid-email");
        }/*from   ww w . j a v a2 s .c o m*/
    }
}

From source file:net.shopxx.dao.impl.AdminDaoImpl.java

public Admin findByUsername(String username) {
    if (StringUtils.isEmpty(username)) {
        return null;
    }// w  w w . j av  a 2s  .  c o  m
    try {
        String jpql = "select admin from Admin admin where lower(admin.username) = lower(:username)";
        return entityManager.createQuery(jpql, Admin.class).setParameter("username", username)
                .getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.dovemq.api.ConnectionFactory.java

/**
 * Initialize DoveMQ runtime with a supplied endpointId. The endpointId
 * allows the runtime to be distinguishable from other DoveMQ endpoints on
 * the same machine, and also uniquely addressable.
 *
 * @param endpointID//  ww w . j  a va  2s.  com
 */
public static void initialize(String endpointID) {
    if (endpointId == null) {
        if (StringUtils.isEmpty(endpointID)) {
            throw new IllegalArgumentException("Null EndpointID specified");
        }

        DoveMQEndpointDriver.initialize(endpointID);
        endpointId = CAMQPConnectionManager.getContainerId();
    }
}

From source file:net.shopxx.service.impl.ParameterValueServiceImpl.java

public void filter(List<ParameterValue> parameterValues) {
    CollectionUtils.filter(parameterValues, new Predicate() {
        public boolean evaluate(Object object) {
            ParameterValue parameterValue = (ParameterValue) object;
            if (parameterValue == null || StringUtils.isEmpty(parameterValue.getGroup())) {
                return false;
            }/*from  ww w  .j a  va 2 s  .  co  m*/
            CollectionUtils.filter(parameterValue.getEntries(), new Predicate() {
                private Set<String> set = new HashSet<String>();

                public boolean evaluate(Object object) {
                    ParameterValue.Entry entry = (ParameterValue.Entry) object;
                    return entry != null && StringUtils.isNotEmpty(entry.getName())
                            && StringUtils.isNotEmpty(entry.getValue()) && set.add(entry.getName());
                }
            });
            return CollectionUtils.isNotEmpty(parameterValue.getEntries());
        }
    });
}

From source file:com.mmj.app.common.authority.AuthorityHelper.java

/**
 * @param role??, 0101001001000000000/* w w w.ja  v a2s.  co  m*/
 * @return List<Right>
 */
public static Collection<Right> createRightList(String role) {
    if (StringUtils.isEmpty(role)) {
        return Collections.<Right>emptyList();
    }
    List<Right> rightList = new ArrayList<Right>();
    for (Right right : Right.values()) {
        boolean has = hasAuthority(right.getIndex(), role);
        if (has) {
            rightList.add(right);
        }
    }
    return rightList;
}