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.github.luluvise.droid_utils.logging.LogUtils.java

/**
 * Logs a message in LogCat, only if application debugging is active.  Logcat has a message
 * length limitation of ~4000 chars, so if the logMessage is > 4000 chars, recursively print
 * 4000 characters of the logMessage until all chars are logged.
 *
 * @param logLevel//from www .  ja  v a  2s. c  om
 *            The log level to use: must be one of the level constants
 *            provided by the {@link Log} class.
 * @param logTag
 * @param logMessage
 */
public static void log(int logLevel, String logTag, String logMessage) {

    if (!Strings.isNullOrEmpty(logMessage)) {
        if (logMessage.length() > 4000) {
            logHelper(logLevel, logTag, logMessage.substring(0, 4000));
            log(logLevel, logTag, logMessage.substring(4000));
        } else {
            logHelper(logLevel, logTag, logMessage);
        }
    }

}

From source file:de.cbb.mplayer.trees.filter.TuneFilterByStringPrediate.java

@Override
public boolean test(Object t) {
    TreeItemValue item = (TreeItemValue) t;
    if (Strings.isNullOrEmpty(input[0]))
        return true;
    String value = input[0].toLowerCase();
    if (item.getTune() == null) {
        return value.equals(item.getTitle().toLowerCase());
    } else {/*ww  w.j a va 2s  .c o m*/
        if (value.contains(":")) {
            String fieldname = value.substring(0, value.indexOf(":"));
            value = value.substring(value.indexOf(":") + 1);
            switch (fieldname.toLowerCase()) {
            case "title":
                return item.getTune().getTitle().toLowerCase().contains(value);
            case "album":
                return item.getTune().getAlbum().toLowerCase().contains(value);
            case "artist":
                return item.getTune().getArtist().toLowerCase().contains(value);
            case "filename":
                return item.getTune().getFilename().toLowerCase().contains(value);
            case "lyricstext":
                return item.getTune().getLyricsText().toLowerCase().contains(value);
            case "path":
                return item.getTune().getPath().toLowerCase().contains(value);
            default:
                break;
            }
        }
    }
    return containedInAnyField(item, value);

}

From source file:org.apache.isis.core.metamodel.facets.object.encodeable.annotcfg.EncodableFacetAnnotation.java

private static String encoderDecoderName(final Class<?> annotatedClass, final IsisConfiguration configuration) {
    final Encodable annotation = annotatedClass.getAnnotation(Encodable.class);
    final String encoderDecoderName = annotation.encoderDecoderName();
    if (!Strings.isNullOrEmpty(encoderDecoderName)) {
        return encoderDecoderName;
    }/*from ww  w. j a v a  2s  .c  o m*/
    return EncoderDecoderUtil.encoderDecoderNameFromConfiguration(annotatedClass, configuration);
}

From source file:com.google.apps.easyconnect.easyrp.client.basic.util.IdpUtils.java

/**
 * Checks if a email is valid.//  www .  jav  a 2 s.  com
 * 
 * @param email the email address to be checked
 * @return ture for valid, false otherwise
 */
public static boolean isValidEmail(String email) {
    if (Strings.isNullOrEmpty(email)) {
        return false;
    }
    return email.matches(EMAIL_REGEX);
}

From source file:tech.beshu.ror.acl.blocks.rules.impl.XForwardedForSyncRule.java

private static String getXForwardedForHeader(Map<String, String> headers) {
    String header = headers.get("X-Forwarded-For");
    if (!Strings.isNullOrEmpty(header)) {
        String[] parts = header.split(",");
        if (!Strings.isNullOrEmpty(parts[0])) {
            return parts[0].trim();
        }/*  www. j  a v a 2  s  .  c  o  m*/
    }
    return null;
}

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

public static Optional<Architecture> tryGetByCode(ObjectContext context, final String code) {
    Preconditions.checkNotNull(context, "the context must be provided");
    Preconditions.checkState(!Strings.isNullOrEmpty(code));
    return getAll(context).stream().filter(a -> a.getCode().equals(code)).collect(SingleCollector.optional());
}

From source file:com.gsr.myschool.server.repos.spec.UserSpec.java

public static Specification<User> lastnameLike(final String name) {
    return new Specification<User>() {
        @Override//from w  w w  . j a va  2 s.c om
        public Predicate toPredicate(Root<User> userRoot, CriteriaQuery<?> query, CriteriaBuilder cb) {
            String likePattern = Strings.isNullOrEmpty(name) ? "%" : "%" + name + "%";
            return cb.like(userRoot.<String>get("lastName"), likePattern);
        }
    };
}

From source file:com.google.devtools.cyclefinder.TypeCollector.java

public static String getNameForType(ITypeBinding type) {
    String name = renamings.get(type);
    if (name != null) {
        return name;
    }// w w  w .ja  v a2 s. co  m
    name = type.getName();
    if (!Strings.isNullOrEmpty(name)) {
        return name;
    }
    return type.getKey();
}

From source file:de.cbb.mplayer.trees.filter.TuneFilterByInputPrediate.java

@Override
public boolean test(Object t) {
    TreeItemValue item = (TreeItemValue) t;
    if (Strings.isNullOrEmpty(input.getText()))
        return true;
    String value = input.getText().toLowerCase();
    if (item.getTune() == null) {
        return value.equals(item.getTitle().toLowerCase());
    } else {//ww w. j  a  v  a  2 s .  com
        if (value.contains(":")) {
            String fieldname = value.substring(0, value.indexOf(":"));
            value = value.substring(value.indexOf(":") + 1);
            switch (fieldname.toLowerCase()) {
            case "title":
                return item.getTune().getTitle().toLowerCase().contains(value);
            case "album":
                return item.getTune().getAlbum().toLowerCase().contains(value);
            case "artist":
                return item.getTune().getArtist().toLowerCase().contains(value);
            case "filename":
                return item.getTune().getFilename().toLowerCase().contains(value);
            case "lyricstext":
                return item.getTune().getLyricsText().toLowerCase().contains(value);
            case "path":
                return item.getTune().getPath().toLowerCase().contains(value);
            default:
                break;
            }
        }
    }
    return containedInAnyField(item, value);

}

From source file:org.apache.isis.core.progmodel.facets.members.order.MemberOrderFacetAbstract.java

private static String valueElse(final String name, final String string) {
    return !Strings.isNullOrEmpty(name) ? name : string;
}