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:org.excalibur.core.cloud.api.ProviderFactory.java

@Deprecated
public static Provider instance(String kclass) {
    Preconditions.checkState(!Strings.isNullOrEmpty(kclass));
    return (Provider) new Mirror().on(kclass).invoke().constructor().withoutArgs();
}

From source file:com.google.gerrit.httpd.LoginUrlToken.java

public static String getToken(final HttpServletRequest req) {
    String token = req.getPathInfo();
    if (Strings.isNullOrEmpty(token)) {
        return DEFAULT_TOKEN;
    }//from ww  w  . j  a v  a  2  s.c o  m
    return CharMatcher.is('/').trimLeadingFrom(token);
}

From source file:org.incode.module.base.dom.utils.MessageUtils.java

public static String normalize(final Exception ex) {
    if (ex == null || Strings.isNullOrEmpty(ex.getMessage())) {
        return null;
    }//from   ww  w.  j  av  a2s.  c  om
    String message = ex.getMessage();
    final Matcher matcher = pattern.matcher(message);
    if (matcher.matches()) {
        return matcher.group(1);
    }
    return message;
}

From source file:org.onehippo.cms7.essentials.dashboard.utils.PayloadUtils.java

public static String[] extractValueArray(final String value) {
    if (Strings.isNullOrEmpty(value)) {
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }//  www .  j  av a  2 s.c o m
    final List<String> strings = extractValueList(value);
    return strings.toArray(new String[strings.size()]);
}

From source file:com.zaradai.kunzite.trader.services.md.eod.compact.CompactIO.java

public static String getFilename(String folder, String symbol) {
    checkArgument(!Strings.isNullOrEmpty(folder));
    checkArgument(!Strings.isNullOrEmpty(symbol));

    StringBuilder sb = new StringBuilder(folder);

    if (folder.charAt(folder.length() - 1) != File.separatorChar) {
        sb.append(File.separatorChar);
    }/*from w w  w .  ja v a2  s  .  c o  m*/
    sb.append(symbol);
    sb.append(".");
    sb.append(FILE_EXT);

    return sb.toString();
}

From source file:uapi.helper.ClassHelper.java

public static String makeSetterName(String fieldName, boolean isCollection, boolean isMap) {
    if (Strings.isNullOrEmpty(fieldName)) {
        throw new IllegalArgumentException("The field name can't be empty or null");
    }// w  w w .j  av a 2s  .  c om
    String propName;
    if (fieldName.startsWith(FIELD_PREFIX)) {
        propName = fieldName.substring(1);
    } else {
        propName = fieldName;
    }
    String setterName;
    if (isCollection) {
        propName = WordHelper.singularize(propName);
        setterName = ADD_PREFIX + propName.substring(0, 1).toUpperCase()
                + propName.substring(1, propName.length());
    } else if (isMap) {
        propName = WordHelper.singularize(propName);
        setterName = PUT_PREFIX + propName.substring(0, 1).toUpperCase()
                + propName.substring(1, propName.length());
    } else {
        setterName = SETTER_PREFIX + propName.substring(0, 1).toUpperCase()
                + propName.substring(1, propName.length());
    }
    return setterName;
}

From source file:org.haiku.haikudepotserver.dataobjects.PkgUrlType.java

public static Optional<PkgUrlType> getByCode(ObjectContext context, String code) {
    Preconditions.checkArgument(null != context, "the context must be supplied");
    Preconditions.checkArgument(!Strings.isNullOrEmpty(code), "a code is required to get the url type");
    return getAll(context).stream().filter(put -> put.getCode().equals(code))
            .collect(SingleCollector.optional());
}

From source file:com.palantir.docker.compose.connection.State.java

public static State parseFromDockerComposePs(String psOutput) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(psOutput), "No container found");
    Matcher matcher = STATE_PATTERN.matcher(psOutput);
    Preconditions.checkState(matcher.find(), "Could not parse status: %s", psOutput);
    String matchedStatus = matcher.group(STATE_INDEX);
    return valueOf(matchedStatus);
}

From source file:com.flipkart.foxtrot.core.util.TableUtil.java

public static String getTableName(final HbaseConfig hbaseConfig, final Table table) {
    if (table.isSeggregatedBackend()) {
        final String tablePrefix = hbaseConfig.getSeggregatedTablePrefix();
        if (!Strings.isNullOrEmpty(tablePrefix)) {
            return String.format("%s%s", tablePrefix, table.getName());
        } else {/*from ww  w .ja v  a 2  s  .  co  m*/
            return table.getName();
        }
    }
    return hbaseConfig.getTableName();
}

From source file:fr.rjoakim.android.jonetouch.util.SharePreferencesUtils.java

public static boolean isAppLocked(Activity activity) {
    return Strings.isNullOrEmpty(getKey(activity));
}