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.assignmentone.handler.LoginHandler.java

@RequestHandler
public LoginFailure doLogin(String flag) throws LoginFailure {
    if (StringUtils.isEmpty(flag)) {
        return null;
    }/*  ww w .j  a  v  a 2  s .com*/
    if ("error".equals(flag)) {
        throw new LoginFailure();
    }
    if (!Boolean.parseBoolean(flag)) {
        return new LoginFailure();
    }
    return null;
}

From source file:com.arvato.thoroughly.exception.TmallAppException.java

private static String parseTaobaoResponse(String code, TaobaoResponse taobaoResponse) {
    String msg = taobaoResponse.getSubMsg();
    if (StringUtils.isEmpty(msg)) {
        msg = taobaoResponse.getSubCode();
    }/*www .j av a  2  s  .  com*/
    return initErrorMessage(code, msg, null);
}

From source file:de.micromata.genome.logging.HttpSessionIdFiller.java

@Override
public String getValue(LogWriteEntry lwe, LoggingContext ctx) {
    if (ctx == null || StringUtils.isEmpty(ctx.getSessionId()) == true) {
        return null;
    }/*from  w w  w  . j  av  a2s .co m*/
    return ctx.getSessionId();
}

From source file:com.glaf.template.engine.freemarker.DirectiveUtils.java

static String getRequiredParam(Map params, String key) throws TemplateException {
    Object value = params.get(key);
    if (value == null || StringUtils.isEmpty(value.toString())) {
        throw new TemplateModelException("not found required parameter:" + key + " for directive");
    }/*from   w  ww  . j  ava  2 s.c o  m*/
    return value.toString();
}

From source file:alluxio.underfs.glusterfs.GlusterFSCluster.java

private void checkGlusterConfigured() {
    if (StringUtils.isEmpty(Configuration.get(PropertyKey.UNDERFS_GLUSTERFS_MOUNTS))) {
        throw new IllegalArgumentException("Gluster FS Mounts are undefined");
    }//www.j a v  a2  s  .  c  o  m
    if (StringUtils.isEmpty(Configuration.get(PropertyKey.UNDERFS_GLUSTERFS_VOLUMES))) {
        throw new IllegalArgumentException("Gluster FS Volumes are undefined");
    }
}

From source file:com.micromux.cassandra.jdbc.SpashScreenTest.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);
    }/*  w  ww  .  j a v a2 s.c  om*/

    Class.forName("com.micromux.cassandra.jdbc.CassandraDriver");
    con = DriverManager.getConnection(
            String.format("jdbc:cassandra://%s:%d/%s?%s&version=3.0.0", 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);
    stmt = con.createStatement();
    stmt.execute(createKS);

    // Use Keyspace
    String useKS = String.format("USE %s;", KEYSPACE);
    stmt.execute(useKS);

    // Create the target Column family
    String create = "CREATE COLUMNFAMILY Test (KEY text PRIMARY KEY, a bigint, b bigint) ;";
    stmt = con.createStatement();
    stmt.execute(create);
    stmt.close();
    con.close();

    // open it up again to see the new CF
    con = DriverManager
            .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, KEYSPACE, OPTIONS));
}

From source file:ch.citux.td.util.FormatUtils.java

public static String formatGame(String game) {
    return StringUtils.isEmpty(game) ? EMPTY_GAME_PLACEHOLDER : game;
}

From source file:efx.data.model.DefaultPropertyConversionExceptionHandler.java

@Override
public void process(AbstractModel model, String fieldName, String message) {
    if (StringUtils.isEmpty(message)) {
        message = ResourceBundle.getBundle("efx/resource/message").getString("error.value.invalid");
    }/*from w w  w  .  j  av a  2s  .c  om*/
    model.setErrorField(fieldName, message);
}

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

public CookieStoreBuilder setUseCookies(String useCookies) {
    if (!StringUtils.isEmpty(useCookies)) {
        this.useCookies = useCookies;
    }//from w  w  w  .  ja  v a2s .co  m
    return this;
}

From source file:net.pms.Messages.java

public static String getString(String key, String lang) {
    if (StringUtils.isEmpty(lang)) {
        return getString(key);
    }/*from  w  w w .j a  v  a  2s.com*/
    Locale l = new Locale(lang);
    ResourceBundle rb = ResourceBundle.getBundle(BUNDLE_NAME, l);
    if (rb == null) {
        rb = RESOURCE_BUNDLE;
    }
    return getString(key, rb);
}