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.braffdev.server.core.module.mapping.MappingType.java

/**
 * @param uri/*from   ww w . jav a2s. c o  m*/
 * @return
 */
public static MappingType get(String uri) {
    if (StringUtils.isNotBlank(uri)) {
        if (uri.contains(Constants.Mapping.REGEX_WILDCARD_SECTION)
                || uri.contains(Constants.Mapping.REGEX_WILDCARD)) {
            return WILDCARD;
        }
    }

    return DIRECT;
}

From source file:com.netflix.metacat.common.server.properties.PropertyUtils.java

/**
 * Convert a delimited string into a List of {@code QualifiedName}.
 *
 * @param names     The list of names to split
 * @param delimiter The delimiter to use for splitting
 * @return The list of qualified names/*from ww w.ja  v  a2  s. co  m*/
 */
static List<QualifiedName> delimitedStringsToQualifiedNamesList(@Nonnull @NonNull final String names,
        final char delimiter) {
    if (StringUtils.isNotBlank(names)) {
        return Splitter.on(delimiter).omitEmptyStrings().splitToList(names).stream()
                .map(QualifiedName::fromString).collect(Collectors.toList());
    } else {
        return Lists.newArrayList();
    }
}

From source file:com.test.edusys.common.utils.UserUtils.java

public static String hiddenTelephone(String yddh) {
    if (StringUtils.isNotBlank(yddh)) {
        int len = yddh.length();
        if (len >= 4) {
            String lastFour = yddh.substring(len - 4, len - 1);
            return yddh.replace(lastFour, "****");
        }//from  www  . j a  v a 2  s  .c  o m
    }
    return "";
}

From source file:com.lynn.controller.Model.java

@RequestMapping(value = "/A.do")
public ModelAndView A(String type) {
    ModelAndView mv = new ModelAndView();
    System.out.println("com.lynn.controller.Model.A()");
    if (StringUtils.isNotBlank(type)) {
        mv.setViewName("redirect:/model/B1.do");
        return mv;
    }//from  ww  w. j a  va  2  s.c  om
    mv.setViewName("redirect:/model/B.do");
    return mv;
}

From source file:com.vmware.photon.controller.common.dcp.validation.NotBlankValidator.java

public static void validate(ServiceDocument state) {
    try {/*from  ww  w .jav  a 2s  .  co m*/
        Field[] declaredFields = state.getClass().getDeclaredFields();
        for (Field field : declaredFields) {
            Annotation[] declaredAnnotations = field.getDeclaredAnnotations();
            for (Annotation annotation : declaredAnnotations) {
                if (annotation.annotationType() == NotBlank.class) {
                    checkState(null != field.get(state), String.format("%s cannot be null", field.getName()));
                    if (String.class.equals(field.getType())) {
                        checkState((StringUtils.isNotBlank((String) field.get(state))),
                                String.format("%s cannot be blank", field.getName()));
                    }
                }
            }
        }
    } catch (IllegalStateException e) {
        throw e;
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}

From source file:com.weibo.api.motan.protocol.yar.YarProtocolUtil.java

public static String getYarPath(Class<?> interfaceClazz, URL url) {
    if (interfaceClazz != null) {
        YarConfig config = interfaceClazz.getAnnotation(YarConfig.class);
        if (config != null && StringUtils.isNotBlank(config.path())) {
            return config.path();
        }//from  w  w w  . j  a  v a 2  s . co  m
    }
    // '/group/urlpath' as default
    return "/" + url.getGroup() + "/" + url.getPath();
}

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

public static String getBrandByProductId(String productId) {
    String brand = null;// ww  w  .java 2  s.  co m
    if (StringUtils.isNotBlank(productId)) {
        brand = StringUtils.substringBefore(productId, "-");
    }
    return brand;
}

From source file:com.hybris.mobile.utility.JsonUtils.java

/**
 * Return true if the json has the property
 * /*from ww  w .jav  a2s  .com*/
 * @param json
 * @param property
 * @return
 */
public static boolean has(String json, String property) {
    JsonParser parser = new JsonParser();
    JsonObject jsonObject = parser.parse(json).getAsJsonObject();

    return jsonObject.get(property) != null && StringUtils.isNotBlank(jsonObject.get(property).getAsString());
}

From source file:com.norconex.collector.core.pipeline.queue.ReferenceFiltersStageUtil.java

public static boolean resolveReferenceFilters(IReferenceFilter[] filters, BasePipelineContext ctx,
        String type) {/*from w w  w.j  av  a2 s.co  m*/
    if (filters == null) {
        return false;
    }
    String msg = StringUtils.trimToEmpty(type);
    if (StringUtils.isNotBlank(msg)) {
        msg = " (" + msg + ")";
    }

    boolean hasIncludes = false;
    boolean atLeastOneIncludeMatch = false;
    for (IReferenceFilter filter : filters) {
        boolean accepted = filter.acceptReference(ctx.getCrawlData().getReference());

        // Deal with includes
        if (isIncludeFilter(filter)) {
            hasIncludes = true;
            if (accepted) {
                atLeastOneIncludeMatch = true;
            }
            continue;
        }

        // Deal with exclude and non-OnMatch filters
        if (accepted) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("ACCEPTED document reference" + msg + ". Reference="
                        + ctx.getCrawlData().getReference() + " Filter=" + filter);
            }
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("REJECTED document reference " + msg + ". Reference="
                        + ctx.getCrawlData().getReference() + " Filter=" + filter);
            }
            fireDocumentRejected(filter, ctx);
            return true;
        }
    }
    if (hasIncludes && !atLeastOneIncludeMatch) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("REJECTED document reference" + msg + ". No include filters matched. Reference="
                    + ctx.getCrawlData().getReference() + " Filter=[one or more filter 'onMatch' "
                    + "attribute is set to 'include', but none of them were " + "matched]");
        }
        fireDocumentRejected(null, ctx);
        return true;
    }
    return false;
}

From source file:com.qatickets.common.StringHelper.java

public static String crop(String value, int max) {
    if (StringUtils.isNotBlank(value) && value.length() > max) {
        value = value.substring(0, max);
    }//from  w  ww .j  av  a2s. c om
    return value;
}