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

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

Introduction

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

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty ("") and not null.

 StringUtils.isNotEmpty(null)      = false StringUtils.isNotEmpty("")        = false StringUtils.isNotEmpty(" ")       = true StringUtils.isNotEmpty("bob")     = true StringUtils.isNotEmpty("  bob  ") = true 

Usage

From source file:com.gdo.stencils.cond.LinkCondition.java

public static boolean isLinkKey(String key) {
    return (StringUtils.isNotEmpty(key) && key.startsWith("$"));
}

From source file:com.nridge.core.io.gson.IOJSON.java

/**
 * Writes a JSON field name/value if the value is not empty.
 *
 * @param aWriter JSON writer output stream.
 * @param aName Field name./* w w  w. j  a  v a 2  s .  co  m*/
 * @param aValue Field value.
 *
 * @throws IOException I/O related exception.
 */
public static void writeNameValue(JsonWriter aWriter, String aName, String aValue) throws IOException {
    if (StringUtils.isNotEmpty(aValue))
        aWriter.name(aName).value(aValue);
}

From source file:com.baifendian.swordfish.common.utils.http.HttpUtil.java

/**
 *  http  ip ?/*w  w  w . ja  v  a  2s . c  om*/
 */
public static String getClientIpAddress(HttpServletRequest request) {
    String ip = request.getHeader("X-Forwarded-For");

    if (StringUtils.isNotEmpty(ip) && !StringUtils.equalsIgnoreCase("unKnown", ip)) {
        // ????? ip  ip ? ip
        int index = ip.indexOf(",");
        if (index != -1) {
            return ip.substring(0, index);
        } else {
            return ip;
        }
    }

    ip = request.getHeader("X-Real-IP");
    if (StringUtils.isNotEmpty(ip) && !StringUtils.equalsIgnoreCase("unKnown", ip)) {
        return ip;
    }

    return request.getRemoteAddr();
}

From source file:com.thinkbiganalytics.datalake.authorization.service.HadoopAuthorizationService.java

public static List<String> convertNewlineDelimetedTextToList(String text) {
    List<String> result = new ArrayList<>();
    if (StringUtils.isNotEmpty(text)) {
        String listWithCommas = text.replace("\n", ",");
        result = Arrays.asList(listWithCommas.split(",")).stream().collect(Collectors.toList());
    }//from www  .  java  2s  .  c  o m
    return result;
}

From source file:com.dgtlrepublic.anitomyj.StringHelper.java

/** Returns whether or not the {@code string} is a hex string. */
public static boolean isHexadecimalString(String string) {
    return StringUtils.isNotEmpty(string) && string.chars().allMatch(value -> isHexadecimalChar((char) value));
}

From source file:com.ec2box.manage.db.UserThemeDB.java

/**
 * get user theme/*from   w w w.  ja v a2 s  . c o  m*/
 *
 * @param userId object
 * @return user theme object
 */
public static UserSettings getTheme(Long userId) {

    UserSettings theme = null;
    Connection con = null;
    try {
        con = DBUtils.getConn();

        PreparedStatement stmt = con.prepareStatement("select * from user_theme where user_id=?");
        stmt.setLong(1, userId);
        ResultSet rs = stmt.executeQuery();
        if (rs.next()) {
            theme = new UserSettings();
            theme.setBg(rs.getString("bg"));
            theme.setFg(rs.getString("fg"));
            if (StringUtils.isNotEmpty(rs.getString("d1"))) {
                String[] colors = new String[16];
                colors[0] = rs.getString("d1");
                colors[1] = rs.getString("d2");
                colors[2] = rs.getString("d3");
                colors[3] = rs.getString("d4");
                colors[4] = rs.getString("d5");
                colors[5] = rs.getString("d6");
                colors[6] = rs.getString("d7");
                colors[7] = rs.getString("d8");
                colors[8] = rs.getString("b1");
                colors[9] = rs.getString("b2");
                colors[10] = rs.getString("b3");
                colors[11] = rs.getString("b4");
                colors[12] = rs.getString("b5");
                colors[13] = rs.getString("b6");
                colors[14] = rs.getString("b7");
                colors[15] = rs.getString("b8");
                theme.setColors(colors);
            }
        }
        DBUtils.closeRs(rs);
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DBUtils.closeConn(con);
    }

    return theme;

}

From source file:at.porscheinformatik.sonarqube.licensecheck.projectLicense.ProjectLicenseService.java

public List<ProjectLicense> getProjectLicenseList() {
    String projectLicenseString = settings.getString(PROJECT_LICENSE_KEY);

    if (StringUtils.isNotEmpty(projectLicenseString)) {
        return ProjectLicense.fromString(projectLicenseString);
    }// w  w w  .j a v  a 2  s .  com

    return new ArrayList<>();
}

From source file:mesosphere.dcos.hazelcast.DcosHazelcastApp.java

private static void setPropertyIfPresent(Config config, String configParam, String envParam,
        String defaultValue) {//from  w ww .ja v  a2 s. com
    String env = System.getenv(envParam);
    if (StringUtils.isNotEmpty(env)) {
        config.setProperty(configParam, env);
    } else {
        config.setProperty(configParam, defaultValue);
    }
}

From source file:de.dhbw.vetaraus.NeticaUtils.java

/**
 * Write a given Netica net to a output file.
 *
 * @param net//  w  ww .  j a va  2 s . co m
 *         The Netica net.
 * @param filename
 *         The output file.
 * @throws NeticaException
 */
static void writeNet(Net net, String filename) throws NeticaException {
    if (StringUtils.isNotEmpty(filename)) {
        net.write(new Streamer(filename));
        System.out.println("Wrote netica net to file " + filename);
    }
}

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

@Override
public void validateNamespace(String input) {
    if (StringUtils.isNotEmpty(input)) {
        validateItem(input, "Error validating system property namespace.");
    }/*from   w  w  w  .ja  v  a2  s.com*/
}