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.qq.tars.validate.ApplicationValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    return StringUtils.isNotBlank(value) && StringUtils.isAlpha(value);
}

From source file:com.sinnerschrader.s2b.accounttool.logic.component.licences.Dependency.java

@Transient
public boolean hasLicenseComment() {
    for (License l : licenses) {
        if (StringUtils.isNotBlank(l.getComments())) {
            return true;
        }//from   w  w w.  j  av  a  2  s . c o  m
    }
    return false;
}

From source file:ch.cyberduck.core.local.WorkspaceBrowserLauncher.java

@Override
public boolean open(final String url) {
    synchronized (NSWorkspace.class) {
        if (StringUtils.isNotBlank(url)) {
            if (NSWorkspace.sharedWorkspace().openURL(NSURL.URLWithString(url))) {
                return true;
            }//from  w w w  .  ja v a  2  s  .com
            log.warn(String.format("Failure opening URL %s with browser", url));
        }
        return false;
    }
}

From source file:com.databasepreservation.visualization.api.utils.ApiUtils.java

/**
 * Get media type//from   ww w  .  ja va 2 s .c o  m
 *
 * @param acceptFormat
 *          String with required format
 * @param acceptHeaders
 *          String with request headers
 * @return media type
 */
public static String getMediaType(String acceptFormat, String acceptHeaders) {
    final String APPLICATION_JS = "application/javascript; charset=UTF-8";

    String mediaType = MediaType.APPLICATION_JSON + "; charset=UTF-8";

    if (StringUtils.isNotBlank(acceptFormat)) {
        if (acceptFormat.equalsIgnoreCase("XML")) {
            mediaType = MediaType.APPLICATION_XML;
        } else if (acceptFormat.equalsIgnoreCase("JSONP")) {
            mediaType = APPLICATION_JS;
        } else if (acceptFormat.equalsIgnoreCase("bin")) {
            mediaType = MediaType.APPLICATION_OCTET_STREAM;
        } else if (acceptFormat.equalsIgnoreCase("html")) {
            mediaType = MediaType.TEXT_HTML;
        }
    } else if (acceptHeaders.contains(MediaType.APPLICATION_XML)) {
        mediaType = MediaType.APPLICATION_XML;
    } else if (acceptHeaders.contains(APPLICATION_JS)) {
        mediaType = APPLICATION_JS;
    }

    return mediaType;
}

From source file:net.gvmtool.api.CandidateVersions.java

CandidateVersion determine(Context context, Path candidateDir, String versionName, GvmOptions options) {
    String candidateName = candidateDir.getFileName().toString();

    if (options.isOffline()) {
        if (StringUtils.isNotBlank(versionName)) {
            if (context.candidateVersionInstalled(candidateDir, versionName)) {
                return version(context, candidateDir, versionName);
            } else {
                throw new RuntimeException("Not available offline");
            }//from w  w w  .  j a  v a2  s. com
        } else {
            if (context.candidateHasCurrentVersion(candidateDir)) {
                Path resolvedCurrentDir = context.candidateResolveCurrentDir(candidateDir);
                return version(context, candidateDir, resolvedCurrentDir.getFileName().toString());
            } else {
                throw new RuntimeException("Not available offline");
            }
        }
    } else {
        if (StringUtils.isBlank(versionName)) {
            Version defaultVersion;
            try {
                defaultVersion = context.getClient().getDefaultVersionFor(candidateName);
            } catch (GvmClientException e) {
                throw new RuntimeException("Error getting default version for " + candidateName, e);
            }
            return version(context, candidateDir, defaultVersion.getName());
        } else {
            boolean versionValid;
            try {
                versionValid = context.getClient().validCandidateVersion(candidateName, versionName);
            } catch (GvmClientException e) {
                throw new RuntimeException("Error validating version " + versionName + " of " + candidateName,
                        e);
            }
            if (versionValid) {
                return version(context, candidateDir, versionName);
            }
            if (context.candidateVersionIsSymlink(candidateDir, versionName)) {
                return version(context, candidateDir, versionName);
            }
            if (context.candidateVersionIsDir(candidateDir, versionName)) {
                return version(context, candidateDir, versionName);
            }

            throw new RuntimeException(versionName + " is not a valid " + candidateName + " version.");
        }
    }
}

From source file:ch.cyberduck.core.DefaultPathReference.java

public String attributes() {
    String qualifier = StringUtils.EMPTY;
    if (StringUtils.isNotBlank(file.attributes().getRegion())) {
        if (containerService.isContainer(file)) {
            qualifier += file.attributes().getRegion();
        }//from ww  w  .j  av  a 2 s  . c  om
    }
    if (StringUtils.isNotBlank(file.attributes().getVersionId())) {
        qualifier += file.attributes().getVersionId();
    }
    return qualifier;
}

From source file:de.blizzy.documentr.markdown.MacroInvocationTest.java

@Test
public void getStartMarker() {
    assertTrue(StringUtils.isNotBlank(invocation.getStartMarker()));
}

From source file:com.cognifide.aet.job.common.comparators.source.visitors.ContentVisitor.java

@Override
public void visit(Node node) {
    if (node instanceof TextNode) {
        String text = ((TextNode) node).text();
        if (StringUtils.isNotBlank(text)) {
            formattedTextBuilder.append(text).append("\n");
        }/*from ww  w .  ja va 2 s  . co  m*/
    }
}

From source file:com.thinkbiganalytics.servicemonitor.support.ServiceMonitorCheckUtil.java

/**
 * get a map of the Service and any components that should be checked within that service.
 *//* w w w .j  av a 2s .com*/
public static Map<String, List<String>> getMapOfServiceAndComponents(String services) {
    Map<String, List<String>> map = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    if (StringUtils.isNotBlank(services)) {
        String finalServiceString = services;
        if (services.contains("/")) {
            int i = 1;
            String serviceName = null;
            for (String servicePart : StringUtils.split(services, "/")) {
                //service name is the first string before the /

                if (serviceName == null) {
                    if (servicePart.contains(",")) {
                        serviceName = StringUtils.substringAfterLast(servicePart, ",");
                    } else {
                        serviceName = servicePart;
                    }
                } else {
                    String components = "";
                    String origComponents = "";
                    if (servicePart.contains("]")) {
                        components = StringUtils.substringBeforeLast(servicePart, "]");
                        components = StringUtils.substringAfter(components, "[");
                        origComponents = "[" + components + "]";
                    } else {
                        components = StringUtils.substringBefore(servicePart, ",");
                        origComponents = components;
                    }
                    String[] componentsArr = StringUtils.split(components, ",");
                    map.put(serviceName, Arrays.asList(componentsArr));

                    //now remove these from the finalServiceString
                    finalServiceString = StringUtils.replace(finalServiceString,
                            serviceName + "/" + origComponents, "");

                    //reset serviceName
                    serviceName = StringUtils.substringAfterLast(servicePart, ",");

                }
                i++;
            }
        }

        for (String service : StringUtils.split(finalServiceString, ",")) {
            String serviceName = service;
            map.put(serviceName, Arrays.asList(new String[] { ALL_COMPONENTS }));
        }
    }
    return map;
}

From source file:com.github.rvesse.airline.types.numerics.NumericCandidate.java

public boolean hasPrefix() {
    return StringUtils.isNotBlank(this.prefix);
}