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:io.teak.sdk.RemoteConfiguration.java

private static String nullInsteadOfEmpty(String input) {
    if (input != null && !input.isEmpty()) {
        return input;
    }/*from   w w w.jav  a 2 s. c om*/
    return null;
}

From source file:com.fjn.helper.common.util.StringUtil.java

public static boolean isOk(String str) {
    return str != null && !str.isEmpty() && !str.trim().isEmpty();
}

From source file:com.ibm.dgaasx.config.EnvironmentInfo.java

public static final DGaaSInfo parseVCAPS() {
    DGaaSInfo info = new DGaaSInfo();

    String vcaps = System.getenv("VCAP_SERVICES");

    if (vcaps == null || vcaps.trim().isEmpty() || "{}".equals(vcaps)) {
        String dgaasURL = SystemUtils.getSystemProperty("DGAAS_URL", null);
        info.setURL(dgaasURL == null || dgaasURL.isEmpty() ? "https://giediprime:9443/dgaas" : dgaasURL);

        log.info("No VCAPS detected. Using default DGaaS URL: " + dgaasURL);

        return info;
    }/*  www  . j  a  v a 2 s  . c  o  m*/

    JSONObject jsonRoot = new JSONObject(vcaps);
    JSONObject docgenJSON = (JSONObject) jsonRoot.getJSONArray("Document Generation").get(0);
    JSONObject credentialsJSON = docgenJSON.getJSONObject("credentials");

    info.setURL(credentialsJSON.getString("url"));
    info.setInstanceID(credentialsJSON.getString("instanceid"));
    info.setRegion(credentialsJSON.getString("region"));

    log.info("VCAPS detected. DgaaS URL is: " + info.getURL());

    return info;
}

From source file:biospectra.ClientConfiguration.java

public static ClientConfiguration createInstance(String json) throws IOException {
    if (json == null || json.isEmpty()) {
        throw new IllegalArgumentException("json is empty or null");
    }//from ww  w . ja  v  a 2 s. c  o  m

    JsonSerializer serializer = new JsonSerializer();
    return (ClientConfiguration) serializer.fromJson(json, ClientConfiguration.class);
}

From source file:com.github.fge.jackson.jsonpointer.JsonNodeResolver.java

/**
 * Return an array index corresponding to the given (raw) reference token
 *
 * <p>If no array index can be found, -1 is returned. As the result is used
 * with {@link JsonNode#get(int)}, we are guaranteed correct results, since
 * this will return {@code null} in this case.</p>
 *
 * @param raw the raw token, as a string
 * @return the index, or -1 if the index is invalid
 *///from w  w w. j a v a  2 s  . c o m
private static int arrayIndexFor(final String raw) {
    /*
     * Empty? No dice.
     */
    if (raw.isEmpty())
        return -1;
    /*
     * Leading zeroes are not allowed in number-only refTokens for arrays.
     * But then, 0 followed by anything else than a number is invalid as
     * well. So, if the string starts with '0', return 0 if the token length
     * is 1 or -1 otherwise.
     */
    if (raw.charAt(0) == ZERO)
        return raw.length() == 1 ? 0 : -1;

    /*
     * Otherwise, parse as an int. If we can't, -1.
     */
    try {
        return Integer.parseInt(raw);
    } catch (NumberFormatException ignored) {
        return -1;
    }
}

From source file:com.streamreduce.util.SecurityUtil.java

public static boolean isValidPassword(String password) {
    return !(password.isEmpty() || password.length() < 6 || password.length() >= 20);
}

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

private static String getScriptFile(String scriptFile) {
    if (scriptFile == null || scriptFile.isEmpty()) {
        return null;
    }/*from  w w w.  j a  va2 s . com*/
    return scriptFile;
}

From source file:com.vmware.admiral.test.integration.client.ServiceDocument.java

public static String extractId(String documentSelfLink) {
    if (documentSelfLink == null) {
        return null;
    }//from w w w .ja va 2s .c  o m
    String id = StringUtils.substringAfterLast(documentSelfLink, "/");
    if (id == null || id.isEmpty()) {
        return documentSelfLink;
    }
    return id;
}

From source file:com.amazonaws.services.kinesis.clientlibrary.lib.checkpoint.InMemoryCheckpointImpl.java

/** Check that string is neither null nor empty.
 *///from  w w w  .j  a va2  s  .  c  o  m
static void verifyNotEmpty(String string, String message) {
    if ((string == null) || (string.isEmpty())) {
        throw new IllegalArgumentException(message);
    }
}

From source file:com.cloudbees.jenkins.plugins.bitbucket.BitbucketCredentials.java

static FormValidation checkCredentialsId(@AncestorInPath @CheckForNull SCMSourceOwner context,
        @QueryParameter String value, @QueryParameter String serverUrl) {
    if (!value.isEmpty()) {
        if (CredentialsMatchers.firstOrNull(
                CredentialsProvider.lookupCredentials(StandardCertificateCredentials.class, context,
                        context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                                : ACL.SYSTEM,
                        URIRequirementBuilder.fromUri(serverUrl).build()),
                CredentialsMatchers.allOf(CredentialsMatchers.withId(value), AuthenticationTokens
                        .matcher(BitbucketAuthenticator.authenticationContext(serverUrl)))) != null) {
            return FormValidation.warning(
                    "A certificate was selected. You will likely need to configure Checkout over SSH.");
        }//from   www  . jav  a  2 s .  c o  m
        return FormValidation.ok();
    } else {
        return FormValidation.warning("Credentials are required for build notifications");
    }
}