Example usage for java.lang String isEmpty

List of usage examples for java.lang String isEmpty

Introduction

In this page you can find the example usage for java.lang String isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if, and only if, #length() is 0 .

Usage

From source file:Main.java

public static Element firstChildElement(Element element, String childNameSpace, String childName)
        throws NoSuchElementException {
    NodeList childCandidateList;//  ww  w .jav  a 2 s . c om
    if (childNameSpace == null || childNameSpace.isEmpty()) {
        childCandidateList = element.getElementsByTagName(childName);
    } else {
        /*childCandidateList = element.getElementsByTagNameNS(childNameSpace,
          childName);*/
        childCandidateList = element.getElementsByTagNameNS(childNameSpace, childName);
    }
    if (childCandidateList.getLength() > 0) {
        Element firstChild = (Element) childCandidateList.item(0);
        return firstChild;
    } else {
        throw new NoSuchElementException("No child candidate found in this element");
    }
}

From source file:zipkin.autoconfigure.storage.elasticsearch.aws.ZipkinElasticsearchAwsStorageAutoConfiguration.java

private static boolean isEmpty(String s) {
    return s == null || s.isEmpty();
}

From source file:com.github.pjungermann.config.utils.NameUtils.java

/**
 * Returns the natural name representation for the given name, i.e.
 * {@code "MyName"} gets converted to {@code "My Name"}.
 *
 * @param name    the name to create the natural name for.
 * @return the natural name.//from ww w .  ja  va2 s.  co  m
 */
@NotNull
public static String getNaturalName(@NotNull final String name) {
    if (name.isEmpty()) {
        return name;
    }

    final String[] nameParts = splitByCharacterTypeCamelCase(name);
    final StringBuilder builder = new StringBuilder();
    for (final String part : nameParts) {
        builder.append(part).append(" ");
    }

    builder.setLength(builder.length() - 1);
    return builder.toString();
}

From source file:io.apiman.common.util.ApimanPathUtils.java

/**
 * Join endpoint and path with sensible / behaviour.
 *
 * @param endpoint the endpoint/*  w w w. jav  a2 s . com*/
 * @param path the destination (path)
 * @return the joined endpoint + destination.
 */
public static String join(String endpoint, String path) {
    if (endpoint == null || endpoint.isEmpty())
        return path;
    if (path == null || path.isEmpty())
        return endpoint;

    if (StringUtils.endsWith(endpoint, "/") && path.startsWith("/")) {
        return endpoint + path.substring(1);
    } else if (StringUtils.endsWith(endpoint, "/") ^ path.startsWith("/")) {
        return endpoint + path;
    }
    return endpoint + "/" + path;
}

From source file:com.github.christiangda.utils.ip.IP.java

/**
 * @param ip String//  w  ww  .  ja v  a2  s . c o m
 * @return boolean
 */
public static boolean isValidIPV4(String ip) {
    if (ip == null) {
        return false;
    }

    if (ip.isEmpty()) {
        return false;
    }

    return InetAddressUtils.isIPv4Address(ip);
}

From source file:com.github.christiangda.utils.ip.IP.java

/**
 * @param ip String/*from  w  w  w  .  j a va  2  s  .com*/
 * @return boolean
 */
public static boolean isValidIPV6(String ip) {
    if (ip == null) {
        return false;
    }

    if (ip.isEmpty()) {
        return false;
    }

    return InetAddressUtils.isIPv6Address(ip);
}

From source file:com.phoenixnap.oss.ramlapisync.plugin.ClassLoaderUtils.java

public static List<String> loadClasses(MavenProject mavenProject) throws MojoExecutionException {

    List<String> classes = Lists.newArrayList();

    File rootDir = new File(mavenProject.getBuild().getSourceDirectory());
    Collection<File> files = FileUtils.listFiles(rootDir, new SuffixFileFilter(".java"), TrueFileFilter.TRUE);
    for (File file : files) {
        String clazz = file.getName().replace(".java", "");
        if (!clazz.isEmpty()) {
            classes.add(clazz);//ww  w . j  av a  2  s. co m
        }
    }
    return classes;
}

From source file:org.avidj.zuul.rs.Zuul.java

private static List<String> toLockPath(String lockPath) {
    if (lockPath.isEmpty()) {
        return Collections.emptyList();
    }/*from w  w  w .  j  a  v  a 2s .c o  m*/
    return Collections.unmodifiableList(Arrays.asList(lockPath.split("/")));
}

From source file:com.hazelcast.qasonar.listpullrequests.ListPullRequests.java

private static String getOptionalParameters(String optionalParameters) {
    if (optionalParameters == null || optionalParameters.isEmpty()) {
        return "";
    }/*from   w  w  w .  ja v a 2  s  .  c  o  m*/
    return " " + optionalParameters;
}

From source file:com.github.christiangda.utils.ip.IP.java

/**
 * @param ip String/*w ww . j a va 2  s .  co  m*/
 * @return boolean
 */
public static boolean isValidIP(String ip) {

    if (ip == null) {
        return false;
    }

    if (ip.isEmpty()) {
        return false;
    }

    return InetAddressUtils.isIPv4Address(ip) || InetAddressUtils.isIPv6Address(ip);
}