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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

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.

Usage

From source file:com.astamuse.asta4d.data.convertor.String2Enum.java

@Override
public DataValueConvertor<String, Enum> convert(final Class<Enum> targetType) {
    return new DataValueConvertor<String, Enum>() {
        @SuppressWarnings("unchecked")
        @Override/*from www . j a va 2  s  . co m*/
        public Enum convert(String s) throws UnsupportedValueException {
            if (StringUtils.isEmpty(s)) {
                return null;
            }
            return Enum.valueOf(targetType, s);
        }
    };
}

From source file:de.micromata.tpsb.doc.parser.TypeUtils.java

License:asdf

public static boolean isValidJavaIdentifier(String s, boolean withDots) {
    if (StringUtils.isEmpty(s) == true) {
        return false;
    }/*from w ww .j  ava2 s . c om*/
    if (Character.isJavaIdentifierStart(s.charAt(0)) == false) {
        return false;
    }
    for (int i = 1; i < s.length(); ++i) {
        char c = s.charAt(i);
        if (Character.isJavaIdentifierPart(c) == false && (withDots == true && c == '.') == false) {
            return false;
        }
    }
    return true;
}

From source file:de.bund.bva.isyfact.benutzerverwaltung.core.benutzerverwaltung.validation.ValiderBenutzernameValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    return StringUtils.isEmpty(value) || value.matches("[a-zA-Z0-9\\-_.@]+");
}

From source file:com.netflix.spinnaker.clouddriver.model.LoadBalancerInstance.java

public String getName() {
    if (StringUtils.isEmpty(name)) {
        return id;
    } else {
        return name;
    }
}

From source file:com.opensearchserver.extractor.util.Language.java

public static final String detect(String text, int length) throws LangDetectException {
    if (StringUtils.isEmpty(text))
        return null;
    Detector detector = DetectorFactory.create();
    detector.setMaxTextLength(length);/*from ww w  . j  av a  2s  .  co m*/
    detector.append(text);
    return detector.detect();
}

From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings.java

@Override
public String getDeployLocation() {
    return StringUtils.isEmpty(deploymentConfiguration.getDeploymentEnvironment().getLocation()) ? "spinnaker"
            : deploymentConfiguration.getDeploymentEnvironment().getLocation();
}

From source file:minor.login.LoginAction.java

@Override
public void validate() {
    if (StringUtils.isEmpty(getUsername())) {
        addFieldError("username", "Username cannot be blank.");
    }//from  w w  w  .  j a va2s. c om
    if (StringUtils.isEmpty(getPassword())) {
        addFieldError("password", "Password cannot be blank.");
    }
}

From source file:cn.guoyukun.spring.web.controller.DownloadController.java

@RequestMapping(value = "/download")
public String download(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(value = "filename") String filename) throws Exception {

    filename = filename.replace("/", "\\");

    if (StringUtils.isEmpty(filename) || filename.contains("\\.\\.")) {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("??");
        return null;
    }// w  w w.  j ava 2  s.  co  m
    filename = URLDecoder.decode(filename, Constants.ENCODING);

    String filePath = FileUploadUtils.extractUploadDir(request) + "/" + filename;

    DownloadUtils.download(request, response, filePath, prefixFilename + filename);

    return null;
}

From source file:com.github.rvesse.airline.builder.AliasBuilder.java

public AliasBuilder<C> withArgument(String arg) {
    if (StringUtils.isEmpty(arg))
        throw new IllegalArgumentException("Alias argument cannot be null");
    arguments.add(arg);//  www . j a  v a  2s  .c  o  m
    return this;
}

From source file:com.netflix.spinnaker.halyard.config.validate.v1.security.GithubRoleProviderValidator.java

@Override
public void validate(ConfigProblemSetBuilder p, GithubRoleProvider provider) {
    if (StringUtils.isEmpty(provider.getOrganization())) {
        p.addProblem(Problem.Severity.ERROR, "No organization specified.");
    }/*from   ww  w. j a  v  a  2s. co m*/

    if (StringUtils.isEmpty(provider.getAccessToken())) {
        p.addProblem(Problem.Severity.ERROR, "No access token specified.");
    }
}