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:baggage.GitVersion.java

public static String getDate() {
    return StringUtils.isEmpty(date) ? "unknown" : date;
}

From source file:ml.shifu.core.util.ValidationUtils.java

public static void validateTargetFieldExistsAndUnique(FieldMeta fieldMeta, String targetFieldName) {

    if (StringUtils.isEmpty(targetFieldName)) {
        throw new RuntimeException("Empty targetFieldName");
    }/*from  ww  w  .  ja va2  s  . c  o m*/

    int cnt = 0;
    for (Field field : fieldMeta.getFields()) {
        if (field.getName().equals(targetFieldName)) {
            cnt++;
        }
    }

    if (cnt == 0) {
        throw new RuntimeException("Target field does not exist: " + targetFieldName);
    }

    if (cnt > 1) {
        throw new RuntimeException(
                "Duplicated target field: " + targetFieldName + "(" + cnt + " duplicated fields)");
    }
}

From source file:mtsar.api.csv.WorkerCSV.java

public static Iterator<Worker> parse(Stage stage, CSVParser csv) {
    final Set<String> header = csv.getHeaderMap().keySet();
    checkArgument(!Sets.intersection(header, Sets.newHashSet(HEADER)).isEmpty(), "Unknown CSV header: %s",
            String.join(",", header));

    return StreamSupport.stream(csv.spliterator(), false).map(row -> {
        final String id = row.isSet("id") ? row.get("id") : null;
        final String[] tags = row.isSet("tags") && !StringUtils.isEmpty(row.get("tags"))
                ? row.get("tags").split("\\|")
                : new String[0];
        final String datetime = row.isSet("datetime") ? row.get("datetime") : null;

        return new Worker.Builder().setId(StringUtils.isEmpty(id) ? null : Integer.valueOf(id))
                .setStage(stage.getId()).addAllTags(Arrays.asList(tags))
                .setDateTime(new Timestamp(StringUtils.isEmpty(datetime) ? System.currentTimeMillis()
                        : Long.parseLong(datetime) * 1000L))
                .build();/*from w  w w.  j av a  2  s .  c om*/
    }).iterator();
}

From source file:io.cloudslang.lang.compiler.validator.SystemPropertyValidatorImpl.java

@Override
public void validateKey(String input) {
    if (StringUtils.isEmpty(input)) {
        throw new RuntimeException("Key cannot be empty.");
    } else {//w ww.ja  v a  2s .c  o  m
        validateItem(input, "Error validating system property key.");
    }
}

From source file:ch.cyberduck.core.PasswordStrengthValidator.java

public Strength getScore(final String password) {
    if (StringUtils.isEmpty(password)) {
        return Strength.veryweak;
    } else {//from   ww  w.  j a v a2s.c  om
        final int score = zxcvbn
                .measure(password,
                        Collections.singletonList(PreferencesFactory.get().getProperty("application.name")))
                .getScore();
        switch (score) {
        case 0:
            return Strength.veryweak;
        case 1:
            return Strength.weak;
        case 2:
            return Strength.fair;
        case 3:
            return Strength.strong;
        case 4:
        default:
            return Strength.verystrong;
        }
    }
}

From source file:io.cloudslang.content.httpclient.build.RequestConfigBuilder.java

public RequestConfigBuilder setConnectionTimeout(String connectionTimeout) {
    if (!StringUtils.isEmpty(connectionTimeout)) {
        this.connectionTimeout = connectionTimeout;
    }/*w w w  .j av a 2 s .c o  m*/
    return this;
}

From source file:com.astamuse.asta4d.util.i18n.LocalizeUtil.java

public static String createLocalizedKey(String str, Locale locale) {
    if (StringUtils.isEmpty(locale.toLanguageTag())) {
        return str;
    }/*from www . j  a  v  a2  s.  c om*/
    return str + "::" + locale.toLanguageTag();
}

From source file:io.servicecomb.swagger.generator.core.utils.ParamUtils.java

public static String getParameterName(String existName, Method method, int paramIdx) {
    if (StringUtils.isEmpty(existName)) {
        existName = getParameterName(method, paramIdx);
    }/*from   w  ww.j a  v  a 2 s. c om*/

    return existName;
}

From source file:com.thoughtworks.go.validation.LengthValidator.java

public ValidationBean validate(String value) {
    if (StringUtils.isEmpty(value)) {
        return ValidationBean.valid();
    }/*from  w  w w .j  av  a2  s .  c o m*/
    if (value.length() <= length) {
        return ValidationBean.valid();
    } else {
        return ValidationBean.notValid(errorMessage);
    }
}

From source file:com.playersun.jbf.modules.sys.entity.Job.java

@Override
public String getIcon() {
    if (!StringUtils.isEmpty(icon)) {
        return icon;
    }//from  w ww. j  ava 2s  .  c o  m
    if (isRoot()) {
        return getRootDefaultIcon();
    }
    if (isLeaf()) {
        return getLeafDefaultIcon();
    }
    return getBranchDefaultIcon();
}