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:br.com.objectos.way.ssh.ScpUploadChannel.java

static ScpUploadChannel success(Session session, File src, String name) {
    String dest = Strings.isNullOrEmpty(name) ? src.getName() : name;

    ScpUploadChannelBuilder builder = src.isDirectory() ? new ScpUploadChannelBuilderDir(session, src, dest)
            : new ScpUploadChannelBuilderFile(session, src, dest);

    return builder.build();
}

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

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

From source file:uk.co.bubblebearapps.motionaiclient.view.customsetters.VideoViewSetters.java

@BindingAdapter("videoUrl")
public static void setVideoUrl(VideoView videoView, String url) {

    Uri uri = Strings.isNullOrEmpty(url) ? Uri.EMPTY : Uri.parse(url);

    videoView.setVideoURI(uri);//from w w  w. j a  v  a  2  s  .  c o m

    MediaController mediaController = new MediaController(videoView.getContext());
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);

    videoView.start();
}

From source file:aritzh.waywia.util.RenderUtil.java

public static Image getImage(String filename) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(filename), "Image file name must not be null or empty!");
    if (!filename.endsWith(".png"))
        filename += ".png";
    filename = "img/" + filename;
    try {/*from  ww w. jav a2 s.  c  o  m*/
        return new Image(TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(filename)));
    } catch (Exception e) {
        Game.logger.e("Could not load image " + filename, e);
    }
    return null;
}

From source file:com.zaradai.kunzite.trader.filters.FilterRequest.java

public static FilterRequest newInstance(String instrumentId, String portfolioId) {
    checkArgument(!Strings.isNullOrEmpty(instrumentId), "Invalid instrument specified");
    checkArgument(!Strings.isNullOrEmpty(portfolioId), "Invalid portfolio specified");

    return new FilterRequest(instrumentId, portfolioId);
}

From source file:org.incode.eurocommercial.contactapp.dom.util.StringUtil.java

public static String eitherOr(final String role, final String newRole, final String thing) {
    if ((Strings.isNullOrEmpty(role) && Strings.isNullOrEmpty(newRole))
            || (!Strings.isNullOrEmpty(role) && !Strings.isNullOrEmpty(newRole))) {
        return "Must specify either an (existing) " + thing + " or a new " + thing;
    }//  w  ww. j  a  va  2  s .  c  o m
    return null;
}

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

public static Optional<Permission> getByCode(ObjectContext context, final String code) {
    Preconditions.checkArgument(null != context, "the context must be provided");
    Preconditions.checkArgument(!Strings.isNullOrEmpty(code), "the permission code must be provided");
    return getAll(context).stream().filter(p -> p.getCode().equals(code)).collect(SingleCollector.optional());
}

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

public static Optional<UserRatingStability> getByCode(ObjectContext context, String code) {
    Preconditions.checkArgument(null != context, "the context must be supplied");
    Preconditions.checkArgument(!Strings.isNullOrEmpty(code), "the code must be supplied");
    return getAll(context).stream().filter((urs) -> urs.getCode().equals(code)).findFirst();
}

From source file:com.github.jcustenborder.kafka.connect.utils.VersionUtil.java

public static String version(Class<?> cls) {
    String result;/*from  w w w  .j  a v a  2 s  .  c  om*/

    try {
        result = cls.getPackage().getImplementationVersion();

        if (Strings.isNullOrEmpty(result)) {
            result = FALLBACK_VERSION;
        }
    } catch (Exception ex) {
        log.error("Exception thrown while getting error", ex);
        result = FALLBACK_VERSION;
    }
    return result;
}

From source file:uk.co.bubblebearapps.motionaiclient.view.customsetters.TextViewSetters.java

@BindingAdapter("htmlText")
public static void setImageUrl(final TextView textView, String htmlText) {

    if (Strings.isNullOrEmpty(htmlText)) {
        textView.setText(null);/*from  w  w  w  .ja  v a 2  s  .c om*/
        return;
    }

    Spanned html;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        html = Html.fromHtml(htmlText, Html.FROM_HTML_SEPARATOR_LINE_BREAK_DIV);
    } else {
        //noinspection deprecation
        html = Html.fromHtml(htmlText);
    }

    textView.setText(html);
}