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.StringToSponsorConverter.java

@Override
public Sponsor convert(String text) {
    Sponsor result;//from  ww 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 = sponsorRepository.findOne(id);
        }
    } catch (Throwable oops) {
        throw new IllegalArgumentException(oops);
    }

    return result;
}

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

@Override
public Event convert(String source) {

    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {//from  w w  w.j  a  v a  2  s . c o m
        return new Event(Long.valueOf(source));
    }

}

From source file:converters.StringToAcademyConverter.java

@Override
public Academy convert(String text) {
    Academy result;//from   ww  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 = academyRepository.findOne(id);
        }
    } catch (Throwable oops) {
        throw new IllegalArgumentException(oops);
    }

    return result;
}

From source file:converters.StringToPaymentConverter.java

@Override
public Payment convert(String text) {
    Payment result;// w  ww . j  a  v  a2 s.  c om
    int id;

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

    return result;
}

From source file:com.clican.pluto.common.bean.PropertyIntialHashMap.java

public PropertyIntialHashMap(String propertyStr) {
    if (StringUtils.isEmpty(propertyStr)) {
        throw new IllegalArgumentException(
                "The initial property must like 'a'=>{'a1','a2','a3'}; 'b'=>{'b1','b2'}; 'c'=>{}; d=>{d1,d2,d3}; 'e'=>'e1'; f=f1. the value is in '' will be convert to string, the value is not in '' will be convert as a spring bean name");
    }//w  ww.ja  v a  2  s. co m
    this.propertyStr = propertyStr;
}

From source file:com.haulmont.cuba.core.global.TemplateHelper.java

public static String processTemplateFromFile(String templatePath, Map<String, Object> parameterValues) {
    final FileTemplateLoader templateLoader;
    try {//from   w w  w .  ja  va2 s. c o m
        String rootPath = AppContext.getProperty("cuba.templateRootDir");
        if (StringUtils.isEmpty(rootPath))
            rootPath = AppContext.getProperty("cuba.confDir");
        templateLoader = new FileTemplateLoader(new File(rootPath), true);
    } catch (IOException e) {
        throw new RuntimeException("Unable to process template from file", e);
    }
    return __processTemplate(templateLoader, templatePath, parameterValues);
}

From source file:com.prontoitlabs.customexception.service.impl.LoginServceImp.java

@Override
public User login(LoginDto loginDto) throws UserNotFoundException {
    if (StringUtils.isEmpty(loginDto.getUserName()) && StringUtils.isEmpty(loginDto.getPassword())) {
        throw new IllegalArgumentException("Invalid User Name/Password");
    }//from ww  w.  j av  a2s.  com
    User user = userService.findByEmailId(loginDto.getUserName());
    if (!(loginDto.getUserName().equalsIgnoreCase(user.getEmail())
            && loginDto.getPassword().equalsIgnoreCase(user.getPassword()))) {
        throw new UserNotFoundException();
    }
    return userService.findByEmailId(loginDto.getUserName());
}

From source file:com.github.dbourdette.glass.log.joblog.JobLogs.java

/**
 * Try to read given string and set level accordingly.
 * If provided value is empty or misspelled, then level is defaulted to WARN.
 *//*from   www  .ja  v a2  s .com*/
public static void setLevel(String level) {
    if (StringUtils.isEmpty(level)) {
        setLevel(JobLogLevel.WARN);

        return;
    }

    try {
        setLevel(JobLogLevel.valueOf(level));
    } catch (Exception e) {
        LOGGER.warn("{} has an incorrect value ({}) for job, defaulting to WARN",
                JobArgumentBean.LOG_LEVEL_ARGUMENT, level);

        setLevel(JobLogLevel.WARN);
    }
}

From source file:converters.StringToMessageKConverter.java

@Override
public MessageK convert(String text) {
    MessageK result;// w  w w.  j  a  v  a  2 s .  com
    int id;

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

    return result;
}

From source file:converters.StringToEndorserConverter.java

@Override
public Endorser convert(String text) {
    Endorser result;// ww w.  j a  v  a2  s.  c  o  m
    int id;

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

    return result;
}