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.gsr.myschool.server.repos.spec.UserSpec.java

public static Specification<User> firstnameLike(final String name) {
    return new Specification<User>() {
        @Override/*from  www .  j  a  v a2s  .  com*/
        public Predicate toPredicate(Root<User> userRoot, CriteriaQuery<?> query, CriteriaBuilder cb) {
            String likePattern = Strings.isNullOrEmpty(name) ? "%" : "%" + name + "%";
            return cb.like(userRoot.<String>get("firstName"), likePattern);
        }
    };
}

From source file:com.google.cloud.tools.appengine.operations.cloudsdk.internal.args.Args.java

/**
 * Produces the flag form of a string value.
 *
 * @return {@code [--name, value]} or {@code []} if value is null.
 *///from  w  w  w .  j  a  v  a  2  s.c  o m
static List<String> string(String name, @Nullable String value) {
    if (!Strings.isNullOrEmpty(value)) {
        return Arrays.asList("--" + name, value);
    }
    return Collections.emptyList();
}

From source file:com.google.gerrit.httpd.plugins.ContextMapper.java

private static boolean isAuthorizedCall(HttpServletRequest req) {
    return !Strings.isNullOrEmpty(req.getServletPath()) && req.getServletPath().startsWith(AUTHORIZED_PREFIX);
}

From source file:org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateStringAdapter.java

public static LocalDate parse(final String date) {
    if (Strings.isNullOrEmpty(date)) {
        return null;
    }/*  w  ww. j a  v  a 2  s. c  om*/
    return dateFormatter.parseLocalDate(date);
}

From source file:org.gradle.util.Path.java

public static Path path(String path) {
    if (Strings.isNullOrEmpty(path)) {
        throw new InvalidUserDataException("A path must be specified!");
    }//from w  ww.  j ava2  s .co  m
    if (path.equals(SEPARATOR)) {
        return ROOT;
    } else {
        return parsePath(path);
    }
}

From source file:org.apache.isis.schema.utils.jaxbadapters.JodaLocalTimeStringAdapter.java

public static LocalTime parse(final String date) {
    if (Strings.isNullOrEmpty(date)) {
        return null;
    }/* w  ww  . j  a  va  2s  .c om*/
    return dateFormatter.parseLocalTime(date);
}

From source file:qa.qcri.nadeef.web.rest.RuleAction.java

public static void setup(SQLDialect dialect) {
    SQLDialectBase dialectInstance = SQLDialectBase.createDialectBaseInstance(dialect);
    get("/:project/data/rule", (x, response) -> {
        String project = x.params("project");
        if (Strings.isNullOrEmpty(project))
            throw new IllegalArgumentException("Input is not valid.");

        return SQLUtil.query(project, dialectInstance.queryRule(), true);
    });//  ww w  .ja v a  2 s .c  om

    get("/:project/data/rule/:ruleName", (x, response) -> {
        String ruleName = x.params("ruleName");
        String project = x.params("project");
        if (Strings.isNullOrEmpty(project) || Strings.isNullOrEmpty(ruleName))
            throw new IllegalArgumentException("Input is not valid.");

        return SQLUtil.query(project, dialectInstance.queryRule(ruleName), true);
    });

    delete("/:project/data/rule", (x, response) -> {
        HashMap<String, Object> json = HTTPPostJsonParser.parse(x.body());
        @SuppressWarnings("unchecked")
        List<String> ruleNames = (List<String>) json.get("rules");
        String project = (String) json.get("project");

        if (Strings.isNullOrEmpty(project) || ruleNames == null || ruleNames.size() == 0)
            throw new IllegalArgumentException("Input is not valid.");

        for (String ruleName : ruleNames)
            SQLUtil.update(project, dialectInstance.deleteRule(ruleName));
        return 0;
    });

    post("/:project/data/rule", (request, response) -> {
        String project = request.params("project");
        String type = request.queryParams("type");
        String name = request.queryParams("name");
        String table1 = request.queryParams("table1");
        String table2 = request.queryParams("table2");
        String code = request.queryParams("code");
        if (Strings.isNullOrEmpty(type) || Strings.isNullOrEmpty(name) || Strings.isNullOrEmpty(table1)
                || Strings.isNullOrEmpty(code) || Strings.isNullOrEmpty(project))
            throw new IllegalArgumentException("Input is not valid.");

        // Doing a delete and insert
        SQLUtil.update(project, dialectInstance.deleteRule(name));

        return SQLUtil.update(project,
                dialectInstance.insertRule(type.toUpperCase(), code, table1, table2, name));
    });
}

From source file:com.cloudant.common.CouchUtils.java

public static boolean isValidDocumentId(String docId) {
    // http://wiki.apache.org/couch/HTTP_Document_API#Documents
    if (Strings.isNullOrEmpty(docId)) {
        return false;
    }//  w  ww  . j a va 2  s. com

    if (docId.charAt(0) == '_') {
        return (docId.startsWith(CouchConstants._design_prefix)
                || docId.startsWith(CouchConstants._local_prefix));
    }

    return true;
}

From source file:com.fanmei.pay4j.weixin.type.CurrencyType.java

public static CurrencyType of(String type) {
    if (Strings.isNullOrEmpty(type)) {
        return CNY;
    }/*from w ww  . j ava  2s.  c o  m*/
    for (CurrencyType currencyType : CurrencyType.values()) {
        if (currencyType.desc.equals(type)) {
            return currencyType;
        }
    }
    return CNY;
}

From source file:org.killbill.billing.plugin.avatax.client.ClientUtils.java

public static Boolean getBooleanProperty(final Properties properties, final String key) {
    final String property = properties.getProperty(AvaTaxActivator.PROPERTY_PREFIX + key);
    return Strings.isNullOrEmpty(property) ? true : Boolean.valueOf(property);
}