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:app.controller.PinController.java

@GetMapping("/get")
public Response<List<PinData>> getPinData(@RequestParam(value = "uid") String uid) {
    if (StringUtils.isEmpty(uid) || !mAuthService.isExistUser(uid)) {
        return ResultCode.error(ResultCode.USER_AUTH_FAILED);
    }//from w w w  .  jav  a 2s.  c o m

    List<PinData> pinDatas = new ArrayList<>(5);
    int result = mPinService.getPin(uid, pinDatas);
    return ResultCode.get(result, "Get Pin-Data Failed", pinDatas);
}

From source file:com.micromux.cassandra.jdbc.DataSourceTest.java

@BeforeClass
public static void setUpBeforeClass() throws Exception {

    // configure OPTIONS
    if (!StringUtils.isEmpty(TRUST_STORE)) {
        OPTIONS = String.format("trustStore=%s&trustPass=%s", URLEncoder.encode(TRUST_STORE), TRUST_PASS);
    }/*from w  w w .j a  v a2  s.c o  m*/

    Class.forName("com.micromux.cassandra.jdbc.CassandraDriver");
    con = DriverManager
            .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, "system", OPTIONS));
    Statement stmt = con.createStatement();

    // Drop Keyspace
    String dropKS = String.format("DROP KEYSPACE \"%s\";", KEYSPACE);

    try {
        stmt.execute(dropKS);
    } catch (Exception e) {
        /* Exception on DROP is OK */}

    // Create KeySpace
    String createKS = String.format(
            "CREATE KEYSPACE \"%s\" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};",
            KEYSPACE);
    //        String createKS = String.format("CREATE KEYSPACE %s WITH strategy_class = SimpleStrategy AND strategy_options:replication_factor = 1;",KEYSPACE);
    stmt.execute(createKS);
}

From source file:com.amalto.core.save.context.PartialDeleteSimulator.java

public PartialDeleteSimulator(MutableDocument originalDocument, MutableDocument toDeleteDocument, String pivot,
        String key) {//from w w w  .  j a  v a 2s  .c  o m
    this.originalDocument = originalDocument;
    this.toDeleteDocument = toDeleteDocument;
    if (pivot.endsWith("/")) { //$NON-NLS-1$
        this.toDeletePivot = pivot.substring(0, pivot.length() - 1);
    } else {
        this.toDeletePivot = pivot;
    }
    if (!".".equals(key) && !StringUtils.isEmpty(key)) { //$NON-NLS-1$
        this.toDeleteKey = key.startsWith("/") ? key : "/" + key; //$NON-NLS-1$ //$NON-NLS-2$
    } else {
        this.toDeleteKey = StringUtils.EMPTY;
    }
}

From source file:costumetrade.common.verify.CapthaService.java

@Override
public boolean valid(String businessKey, String code) {

    String key = buildKey(businessKey);
    String capthaCode = (String) redisTemplate.opsForValue().get(key);
    if (StringUtils.isEmpty(capthaCode)) {
        return false;
    }//from  w  w  w . java  2  s.c  o  m
    boolean result = capthaCode.equals(code);
    if (result) {
        redisTemplate.delete(key);
    }
    return result;

}

From source file:me.adaptive.che.plugin.server.util.CommandLineBuilder.java

public String build() {
    StringBuilder builder = new StringBuilder(getCommand()).append(' ');
    String[] params = getParameters();
    if (params != null && params.length > 0) {
        for (String param : params) {
            if (!StringUtils.isEmpty(param)) {
                param = org.springframework.util.StringUtils.containsWhitespace(param)
                        ? org.springframework.util.StringUtils.quote(param)
                        : param;//  w  w  w .  java2s.  c o m
                builder.append(param);
                builder.append(' ');
            }
        }
    }
    LOG.debug("command generated: {}", builder.toString());
    return builder.toString();
}

From source file:com.astamuse.asta4d.web.form.flow.classical.ClassicalMultiStepFormFlowSnippetTrait.java

/**
 * //from   w w w. jav a 2s  .c o  m
 * We will treat confirm and complete step as non edit step by default.
 * 
 * <p>
 * From parent:
 * <p>
 * {@inheritDoc}
 * 
 * @return true when the step is confirm/complete by default
 * @see ClassicalMultiStepFormFlowTraitHelper#NonEditSteps
 */
@Override
default boolean renderForEdit(String step, Object form, String fieldName) {
    if (StringUtils.isEmpty(step)) {
        return true;
    } else {
        return !ClassicalMultiStepFormFlowTraitHelper.NonEditSteps.contains(step.toLowerCase());
    }
}

From source file:com.netflix.genie.client.interceptors.UserAgentInsertInterceptor.java

/**
 * Constructor./*from w  w w .  j  a  va2  s  .c  o  m*/
 *
 * @param userAgent The user agent string to use
 */
public UserAgentInsertInterceptor(final String userAgent) {
    if (StringUtils.isEmpty(userAgent)) {
        this.userAgent = DEFAULT_USER_AGENT_STRING;
    } else {
        this.userAgent = userAgent;
    }
}

From source file:de.micromata.genome.gwiki.jetty.CmdLineInput.java

public static boolean ask(String message, boolean defaultYes) {
    System.out.println(message);//from  w  ww.j a  va  2  s . c  om
    do {
        if (defaultYes == true) {
            System.out.print("([Yes]/No): ");
        } else {
            System.out.print("(Yes/[No]): ");
        }
        String inp = StringUtils.trim(readLine());
        inp = inp.toLowerCase();
        if (StringUtils.isEmpty(inp) == true) {
            return defaultYes;
        }
        if (inp.equalsIgnoreCase("y") == true || inp.equalsIgnoreCase("yes") == true) {
            return true;
        }
        if (inp.equalsIgnoreCase("n") == true || inp.equalsIgnoreCase("no") == true) {
            return false;
        }
    } while (true);
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.security.KubernetesSelector.java

@JsonCreator
private KubernetesSelector(@JsonProperty("kind") @NotNull Kind kind, @JsonProperty("key") String key,
        @JsonProperty("values") List<String> values) {
    if (StringUtils.isEmpty(key) && kind != Kind.ANY) {
        throw new IllegalArgumentException("Only an 'any' selector can have no key specified");
    }//  ww w.j  a  v  a  2 s  .c om

    this.kind = kind;
    this.key = key;
    this.values = values;
}

From source file:cherry.foundation.validator.NoMarkupTagValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {

    if (StringUtils.isEmpty(value)) {
        return true;
    }/*from www  .  ja  v  a2  s  .c o m*/

    Matcher matcher = pattern.matcher(value);
    while (matcher.find()) {
        String tag = matcher.group(groupNum).toLowerCase();
        if (acceptable.contains(tag)) {
            continue;
        }
        return false;
    }

    return true;
}