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

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

Introduction

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

Prototype

public static boolean isNotBlank(final CharSequence cs) 

Source Link

Document

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

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

Usage

From source file:com.funtl.framework.smoke.core.modules.sys.utils.DictUtils.java

public static String getDictLabels(String values, String type, String defaultValue) {
    if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(values)) {
        List<String> valueList = Lists.newArrayList();
        for (String value : StringUtils.split(values, ",")) {
            valueList.add(getDictLabel(value, type, defaultValue));
        }//from ww w. j av a2s  .  co  m
        return StringUtils.join(valueList, ",");
    }
    return defaultValue;
}

From source file:ltistarter.model.BaseEntity.java

public static String makeSHA256(String text) {
    String encode = null;//from   w  w  w  . ja va 2 s  . c  o m
    if (StringUtils.isNotBlank(text)) {
        encode = org.apache.commons.codec.digest.DigestUtils.sha256Hex(text);
    }
    return encode;
}

From source file:me.leep.wf.actions.system.UserListAction.java

public String delete() throws Exception {
    if (StringUtils.isNotBlank(rowid) && rowid.length() != 0) {
        userServices.deleteList(rowid.split(","));
    }//from  w w w. ja v a 2 s  .  c  o m
    return SUCCESS;
}

From source file:be.wegenenverkeer.common.resteasy.json.LocalDateTimeConverter.java

@Override
public LocalDateTime fromString(String str) {
    LocalDateTime date = null;/*w w  w. ja  v  a  2 s . c  om*/

    if (StringUtils.isNotBlank(str)) {
        try {
            return iso8601AndOthers.parse(str);
        } catch (IllegalArgumentException iae) {
            // ignore, try next format
            date = null; // dummy
        }
    }
    return date; // empty string
}

From source file:com.u2apple.rt.util.AndroidDeviceUtils.java

public static String getProductName(String brand, String model) {
    if (StringUtils.isNotBlank(brand) && StringUtils.isNotBlank(model)) {
        String productName;//from ww w.j  a  v a2  s. c o m
        if (StringUtils.containsIgnoreCase(model, brand)) {
            int index = model.toLowerCase().indexOf(brand.toLowerCase());
            productName = model.substring(index + brand.length());
        } else {
            productName = model;
        }
        //Remove prefix -.
        productName = StringUtils.removeStart(productName, "-");
        productName = StringUtils.removeStart(productName, "_");
        return productName.replace("_", "-").trim();
    } else {
        return null;
    }
}

From source file:controllers.feedback.FeedbackApp.java

/**
 * //from www.j  a va  2  s.com
 * @return
 */
@BodyParser.Of(BodyParser.Json.class)
@Transactional
public static Result addSuggestion() {
    ObjectNodeResult result = new ObjectNodeResult();
    Suggestion suggestion = new Suggestion();
    JsonNode json = getJson();
    String content = json.findPath("content").asText();
    String userName = json.findPath("userName").asText();
    String email = json.findPath("email").asText();
    String href = json.findPath("href").asText();
    String qq = json.findPath("qq").asText();
    String phone = json.findPath("phone").asText();
    Iterator<JsonNode> iter = json.findPath("attachs").elements();
    while (iter.hasNext()) {
        JsonNode jn = iter.next();
        Long attachId = jn.findValue("attachId").asLong();
        AttachOfSuggestion attach = (AttachOfSuggestion) Attach.queryById(attachId, AttachOfSuggestion.class);
        if (attach != null) {
            suggestion.attach.add(attach);
        }
    }
    if (StringUtils.isNotBlank(content)) {
        content = common.SensitiveWordsFilter.doFilter(content);
        content = common.ReplaceWordsFilter.doFilter(content);
    }
    if (StringUtils.isNotBlank(userName)) {
        userName = common.SensitiveWordsFilter.doFilter(userName);
        userName = common.ReplaceWordsFilter.doFilter(userName);
    }
    if (StringUtils.isNotBlank(href)) {
        href = common.SensitiveWordsFilter.doFilter(href);
        href = common.ReplaceWordsFilter.doFilter(href);
    }
    if (StringUtils.isNotBlank(email)) {
        email = common.SensitiveWordsFilter.doFilter(email);
        email = common.ReplaceWordsFilter.doFilter(email);
    }
    if (StringUtils.isNotBlank(qq)) {
        qq = common.SensitiveWordsFilter.doFilter(qq);
        qq = common.ReplaceWordsFilter.doFilter(qq);
    }
    if (StringUtils.isNotBlank(phone)) {
        phone = common.SensitiveWordsFilter.doFilter(phone);
        phone = common.ReplaceWordsFilter.doFilter(phone);
    }

    suggestion.content = content;
    suggestion.userName = userName;
    suggestion.href = href;
    suggestion.email = email;
    suggestion.qq = qq;
    suggestion.phone = phone;
    suggestion.persist();
    result.successkey("suggestion.success");
    return ok(result.getObjectNode());
}

From source file:com.rjuarez.webapp.tools.TheMovieDatabaseMethod.java

/**
 * Convert a string into an Enum type//w w w .  j av  a  2s  .  co m
 *
 * @param value
 * @return
 */
public static TheMovieDatabaseMethod fromString(final String value) {
    if (StringUtils.isNotBlank(value)) {
        for (final TheMovieDatabaseMethod method : EnumSet.allOf(TheMovieDatabaseMethod.class)) {
            if (value.equalsIgnoreCase(method.value)) {
                return method;
            }
        }
    }

    // We've not found the type!
    throw new IllegalArgumentException("Method '" + value + "' not recognised");
}

From source file:net.packet.serializer.DeviceSerializer.java

@Override
public JsonElement serialize(Device src, Type typeOfSrc, JsonSerializationContext context) {
    final JsonObject jsonObject = new JsonObject();

    if (StringUtils.isNotBlank(src.getHostname())) {
        jsonObject.addProperty("hostname", src.getHostname());
    }/*w ww . j av a  2s  .com*/

    if (null != src.getPlan() && StringUtils.isNotBlank(src.getPlan().getSlug())) {
        jsonObject.addProperty("plan", src.getPlan().getSlug());
    }

    if (null != src.getBillingCycle()) {
        jsonObject.addProperty("billing_cycle", src.getBillingCycle().getValue());
    }

    if (null != src.getOperatingSystem() && StringUtils.isNotBlank(src.getOperatingSystem().getSlug())) {
        jsonObject.addProperty("operating_system", src.getOperatingSystem().getSlug());
    }

    if (null != src.getFacility() && StringUtils.isNotBlank(src.getFacility().getCode())) {
        jsonObject.addProperty("facility", src.getFacility().getCode());
    }

    if (StringUtils.isNotBlank(src.getUserdata())) {
        jsonObject.addProperty("userdata", src.getUserdata());
    }

    if (null != src.isLocked()) {
        jsonObject.addProperty("locked", src.isLocked().booleanValue());
    }

    if (null != src.getFeatures()) {
        final JsonObject features = new JsonObject();
        for (Map.Entry<String, String> entry : src.getFeatures().entrySet()) {
            features.addProperty(entry.getKey(), entry.getValue());
        }
        jsonObject.add("features", features);
    }

    if (null != src.getTags()) {
        final JsonArray tags = new JsonArray();
        for (String tag : src.getTags()) {
            tags.add(context.serialize(tag));
        }
        jsonObject.add("tags", tags);
    }

    return jsonObject;
}

From source file:net.lmxm.ute.UteTestAssert.java

/**
 * Assert not blank./*w  ww.  j a  va2  s.c  om*/
 * 
 * @param Message the message
 * @param value the value
 */
public static void assertNotBlank(final String Message, final String value) {
    assertTrue(StringUtils.isNotBlank(value));
}

From source file:com.hybris.mobile.app.commerce.utils.ProductUtils.java

/**
 * Find the real price for volume pricing product
 *
 * @param quantity// w w  w.  j  av a 2  s. co m
 * @param volumePrices
 * @return
 */
public static Price findVolumePrice(String quantity, List<Price> volumePrices) {

    Price realPrice = null;

    if (volumePrices != null && StringUtils.isNotBlank(quantity)) {
        for (Price price : volumePrices) {

            if (price.getMinQuantity() <= Integer.parseInt(quantity)) {
                realPrice = price;
            }
        }
    }

    return realPrice;

}