Example usage for org.apache.commons.lang StringUtils isBlank

List of usage examples for org.apache.commons.lang StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isBlank.

Prototype

public static boolean isBlank(String str) 

Source Link

Document

Checks if a String is whitespace, empty ("") or null.

Usage

From source file:com.mycompany.filter.AuthorizationRequestFilter.java

@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    String token = requestContext.getHeaderString("Authorization");

    if (StringUtils.isBlank(token)) {

        requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED)
                .entity("User cannot access the resource.").build());
    }/*from   w  ww  .  j a va 2 s  .  c  o m*/
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.model.CoveragePattern.java

/**
 * Create a list of {@link CoveragePattern} from the given {@link java.io.InputStream}
 *
 * @param input containing one {@link CoveragePattern} per line (for a description of the
 * line format see {@link #parseLine(String)}. Empty lines or comments (lines starting
 * with '#') are ignored//www .  ja v  a 2s.  c o m
 *
 * @return the list of {@link CoveragePattern} from the given {@link java.io.InputStream}
 *
 * @throws java.io.IOException in case the {@link java.io.InputStream} can not be read
 */
public static List<CoveragePattern> parse(final InputStream input) throws IOException {
    final List<CoveragePattern> patterns = new ArrayList<>();
    for (final String line : IOUtils.readLines(input)) {
        if (StringUtils.isBlank(line) || (line.charAt(0) == '#')) {
            continue;
        }

        final CoveragePattern pattern = parseLine(line);
        patterns.add(pattern);
    }
    return patterns;
}

From source file:grails.web.HyphenatedUrlConverter.java

public String toUrlElement(String propertyOrClassName) {
    if (StringUtils.isBlank(propertyOrClassName)) {
        return propertyOrClassName;
    }//from w  w  w .j ava  2  s .  c  o  m

    StringBuilder builder = new StringBuilder();
    char[] charArray = propertyOrClassName.toCharArray();
    for (char c : charArray) {
        if (Character.isUpperCase(c)) {
            if (builder.length() > 0) {
                builder.append("-");
            }
            builder.append(Character.toLowerCase(c));
        } else {
            builder.append(c);
        }
    }
    return builder.toString();
}

From source file:edu.duke.cabig.c3pr.dao.query.DataAuditEventQuery.java

public void filterByValue(String attributeName, String previousValue, String currentValue) {

    leftJoinFetch("e.values value");

    if (!StringUtils.isBlank(attributeName)) {
        andWhere("value.attributeName=:" + ATTRIBUTE_NAME);
        setParameter(ATTRIBUTE_NAME, attributeName);

    }//from ww  w  . j  a va  2s.  c  o m
    if (!StringUtils.isBlank(previousValue)) {
        andWhere("value.previousValue=:" + PREVIOS_VALUE);
        setParameter(PREVIOS_VALUE, previousValue);

    }
    if (!StringUtils.isBlank(currentValue)) {
        andWhere("value.currentValue=:" + CURRENT_VALUE);
        setParameter(CURRENT_VALUE, currentValue);

    }
}

From source file:com.enonic.cms.core.security.user.UsernameResolver.java

public String resolveUsername(final StoreNewUserCommand command) {
    userName = command.getUsername();/*from www . j  a  v a 2 s .c o  m*/
    displayName = command.getDisplayName();

    UserFields userFields = command.getUserFields();
    if (userFields != null) {
        setUserInfoFields(userFields);
    }

    String resolvedUsername = doResolve();

    if (StringUtils.isBlank(resolvedUsername)) {
        throw new IllegalArgumentException("Could not resolve user name");
    }

    return stripBlankspaces(resolvedUsername);
}

From source file:com.intuit.tank.util.FilterUtil.java

/**
 * Filters by contains/*from   w  ww .j  a va  2 s .c om*/
 * @param value
 * @param filter
 * @param locale
 * @return
 */
public boolean contains(Object value, Object filter, Locale locale) {
    String filterText = (filter == null) ? null : filter.toString().trim();
    if (StringUtils.isBlank(filterText)) {
        return true;
    }

    if (value == null) {
        return false;
    }
    return StringUtils.containsIgnoreCase(value.toString(), filterText);
}

From source file:de.hybris.platform.accountsummaryaddon.attributehandlers.B2BUseDocumentReferenceDynamicAttributeHandler.java

@Override
public String get(final B2BDocumentPaymentInfoModel ruleSet) {
    final boolean usingDocument = StringUtils.isBlank(ruleSet.getCcTransactionNumber());

    return usingDocument ? ruleSet.getUseDocument().getDocumentNumber() : ruleSet.getCcTransactionNumber();
}

From source file:com.carlomicieli.jtrains.value.constants.Priority.java

/**
 * Parses the string argument as a {@code Priority}.
 *
 * @param str        the string to be parsed
 * @param defaultValue the default {@code Priority} value
 * @return a {@code Priority} value/* ww  w  .j  a  va2 s  .com*/
 */
public static Priority parse(String str, Priority defaultValue) {
    if (StringUtils.isBlank(str)) {
        return defaultValue;
    }
    return EnumUtils.parseEnum(Priority.class, str);
}

From source file:com.mmj.app.common.core.lang.Argument.java

public static boolean isBlank(String argument) {
    return StringUtils.isBlank(argument);
}

From source file:de.codesourcery.planning.demo.SampleResourceType.java

public SampleResourceType(String name) {

    if (StringUtils.isBlank(name)) {
        throw new IllegalArgumentException("name cannot be blank.");
    }//from w  w w.jav a 2 s  .c  o m
    this.name = name;
}