Example usage for com.google.common.base Strings isNullOrEmpty

List of usage examples for com.google.common.base Strings isNullOrEmpty

Introduction

In this page you can find the example usage for com.google.common.base Strings isNullOrEmpty.

Prototype

public static boolean isNullOrEmpty(@Nullable String string) 

Source Link

Document

Returns true if the given string is null or is the empty string.

Usage

From source file:com.zaradai.kunzite.trader.events.MarketData.java

public static MarketData newInstance(String instrumentId, DateTime timestamp, List<MarketDataField> fields) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(instrumentId), "Invalid Instrument");
    Preconditions.checkNotNull(timestamp, "Invalid timestamp");
    Preconditions.checkNotNull(fields, "Invalid fields specified");

    return new MarketData(instrumentId, timestamp, fields);
}

From source file:com.shampan.db.services.StatusController.java

public static void getStatuses(RoutingContext routingContext) {

    String userId;//  w w  w .j a v a 2 s  .c om
    /**
     * Default offset is 0 Default limit is 10 User id is mandatory
     */
    int offset = 0, limit = 0;

    userId = routingContext.request().getParam("userId");
    if (Strings.isNullOrEmpty(userId)) {
        routingContext.response().end("failed");
    }

    /*
     If offset is incorrect then offset will be used as default
     */
    if (!Strings.isNullOrEmpty(routingContext.request().getParam("offset"))) {
        try {
            offset = Integer.parseInt(routingContext.request().getParam("offset"));
        } catch (NumberFormatException nfe) {
            logger.debug(nfe.getMessage());
        }
    }

    /*
     If limit is incorrect then limit will be used as default
     */
    if (!Strings.isNullOrEmpty(routingContext.request().getParam("limit"))) {
        try {
            limit = Integer.parseInt(routingContext.request().getParam("limit"));
        } catch (NumberFormatException nfe) {
            logger.debug(nfe.getMessage());
        }
    }
    routingContext.response().putHeader("content-type", "application/json; charset=utf-8")
            .end(StatusService.getStatuses(userId, offset, limit));
}

From source file:br.com.tecsinapse.exporter.converter.StringTableCellConverter.java

@Override
public String apply(String input) {
    if (Strings.isNullOrEmpty(input)) {
        return "";
    }// ww w.  j av  a2s .c om
    return input.trim();
}

From source file:com.google.gerrit.server.change.HashtagsUtil.java

public static Set<String> extractTags(String input) {
    Set<String> result = new HashSet<>();
    if (!Strings.isNullOrEmpty(input)) {
        Matcher matcher = Pattern.compile(PATTERN).matcher(input);
        while (matcher.find()) {
            result.add(cleanupHashtag(matcher.group()));
        }/* w  w  w.j av a 2  s  .  c o  m*/
    }
    return result;
}

From source file:io.sarl.eclipse.util.Utilities.java

/** Null-safe version parser.
 *
 * @param version - the version string./*from  w w w  .j  a va  2  s.  co  m*/
 * @return the version.
 */
public static Version parseVersion(String version) {
    if (!Strings.isNullOrEmpty(version)) {
        try {
            return Version.parseVersion(version);
        } catch (Throwable exception) {
            //
        }
    }
    return null;
}

From source file:org.richfaces.util.MessageUtil.java

public static String getLabel(FacesContext context, UIComponent component) {
    String label = (String) component.getAttributes().get("label");

    if (Strings.isNullOrEmpty(label)) {
        label = component.getClientId(context);
    }/*from   w w w . ja v  a2 s.  co  m*/

    return label;
}

From source file:com.b2international.snowowl.snomed.core.domain.constraint.SnomedPredicate.java

static String getCharacteristicTypeExpression(final String characteristicTypeId) {
    return Strings.isNullOrEmpty(characteristicTypeId) ? "<" + Concepts.CHARACTERISTIC_TYPE
            : "<<" + characteristicTypeId;
}

From source file:org.attribyte.api.http.NamedValues.java

/**
 * Copies values from an array to an immutable list.
 * Empty or <code>null</code> values are ignored.
 * @param values The input values./*w w  w.  jav  a2  s  .c om*/
 * @return The internal values.
 */
static final ImmutableList<String> copyValues(final String[] values) {
    if (values == null || values.length == 0) {
        return ImmutableList.of();
    } else {
        ImmutableList.Builder<String> builder = ImmutableList.builder();
        for (final String value : values) {
            if (!Strings.isNullOrEmpty(value)) {
                builder.add(value);
            }
        }
        return builder.build();
    }
}

From source file:com.b2international.snowowl.datastore.request.BranchMergeRequest.java

private static String commitMessageOrDefault(final String sourcePath, final String targetPath,
        final String commitMessage) {
    return !Strings.isNullOrEmpty(commitMessage) ? commitMessage
            : String.format("Merge branch '%s' into '%s'", sourcePath, targetPath);
}

From source file:com.parallax.server.blocklyprop.utils.ServletUtils.java

public static String getCdnUrl(String url, boolean isSecure) {
    if (!Strings.isNullOrEmpty(url)) {
        // System.out.println("Geturl: " + url);

        String cdnUrl = Properties.getConfiguration().getString("cdnfiles.baseurl");
        if (isSecure) {
            cdnUrl = cdnUrl.replaceFirst("http://", "https://");
            cdnUrl = Properties.getConfiguration().getString("cdnfiles.baseurl.https", cdnUrl);
        }/*from w w w.j  ava  2 s  . c o  m*/

        return cdnUrl + (url.startsWith("/") ? "" : "/") + url;
    } else {
        System.out.println("Url = null or empty");
        return "";
    }
}