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.todoroo.astrid.tags.TagFilterExposer.java

/** Create filter from new tag object */
private static TagFilter filterFromTag(TagData tag) {
    if (tag == null || Strings.isNullOrEmpty(tag.getName())) {
        return null;
    }/* w ww.j a  v  a 2 s  .  c o m*/
    return new TagFilter(tag);
}

From source file:org.jboss.hal.modelgraph.dmr.ResourceAddress.java

public static ResourceAddress of(String address) {
    if (!Strings.isNullOrEmpty(address) && !"/".equals(address)) {
        ModelNode node = new ModelNode();
        String normalized = address.startsWith("/") ? address.substring(1) : address;
        Splitter.on('/').withKeyValueSeparator('=').split(normalized)
                .forEach((key, value) -> node.add().set(key, value));
        return new ResourceAddress(node);
    }/*from  w w w. j a va2  s  .c  o  m*/
    return new ResourceAddress();
}

From source file:org.onosproject.xosclient.api.VtnPortId.java

/**
 * Returns vtn port identifier with value.
 *
 * @param id id/*  w w w  . ja  v  a2 s.com*/
 * @return instance port id
 */
public static VtnPortId of(String id) {
    checkArgument(!Strings.isNullOrEmpty(id), "VTN port ID cannot be null");
    return new VtnPortId(id);
}

From source file:org.opendaylight.netconf.console.commands.NetconfCommandUtils.java

public static boolean isIpValid(final String deviceIp) {
    if (Strings.isNullOrEmpty(deviceIp)) {
        return false;
    }//from  www . j a v a2s .  c  o m
    Matcher matcher = IP_PATTERN.matcher(deviceIp);
    return matcher.matches();
}

From source file:org.opendaylight.controller.sal.restconf.impl.QueryParametersParser.java

public static WriterParameters parseWriterParameters(final UriInfo info) {
    WriterParameters.WriterParametersBuilder wpBuilder = new WriterParameters.WriterParametersBuilder();
    String param = info.getQueryParameters(false).getFirst(UriParameters.DEPTH.toString());
    if (!Strings.isNullOrEmpty(param) && !"unbounded".equals(param)) {
        try {/*from  www . j ava  2 s . c o m*/
            final int depth = Integer.valueOf(param);
            if (depth < 1) {
                throw new RestconfDocumentedException(new RestconfError(RestconfError.ErrorType.PROTOCOL,
                        RestconfError.ErrorTag.INVALID_VALUE, "Invalid depth parameter: " + depth, null,
                        "The depth parameter must be an integer > 1 or \"unbounded\""));
            }
            wpBuilder.setDepth(depth);
        } catch (final NumberFormatException e) {
            throw new RestconfDocumentedException(new RestconfError(RestconfError.ErrorType.PROTOCOL,
                    RestconfError.ErrorTag.INVALID_VALUE, "Invalid depth parameter: " + e.getMessage(), null,
                    "The depth parameter must be an integer > 1 or \"unbounded\""));
        }
    }
    param = info.getQueryParameters(false).getFirst(UriParameters.PRETTY_PRINT.toString());
    wpBuilder.setPrettyPrint("true".equals(param));
    return wpBuilder.build();
}

From source file:org.sfs.jobs.JobParams.java

public static String getFirstRequiredParam(MultiMap params, String name) {
    String value = getFirstOptionalParam(params, name);
    if (Strings.isNullOrEmpty(value)) {
        JsonObject jsonObject = new JsonObject().put("message", String.format("%s is required", name));

        throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
    } else {//from w  ww .j  a  v  a  2s.  c om
        return value;
    }
}

From source file:org.gradle.internal.component.local.model.DefaultLibraryComponentIdentifier.java

public static String libraryToConfigurationName(String projectPath, String libraryName) {
    if (Strings.isNullOrEmpty(libraryName)) {
        return String.format("project '%s' default library", projectPath);
    }/*w w  w .  ja v a 2 s.com*/
    return String.format("project '%s' library '%s'", projectPath, libraryName);
}

From source file:com.google.gerrit.server.util.LabelVote.java

public static LabelVote parse(String text) {
    checkArgument(!Strings.isNullOrEmpty(text), "Empty label vote");
    if (text.charAt(0) == '-') {
        return create(text.substring(1), (short) 0);
    }//ww  w  .j  a v  a  2 s. c  om
    short sign = 0;
    int i;
    for (i = text.length() - 1; i >= 0; i--) {
        int c = text.charAt(i);
        if (c == '-') {
            sign = (short) -1;
            break;
        } else if (c == '+') {
            sign = (short) 1;
            break;
        } else if (!('0' <= c && c <= '9')) {
            break;
        }
    }
    if (sign == 0) {
        return create(text, (short) 1);
    }
    return create(text.substring(0, i), (short) (sign * Short.parseShort(text.substring(i + 1))));
}

From source file:com.google.gwt.resources.gss.ast.CssDotPathNode.java

public static String resolveExpression(String instance, String path, String prefix, String suffix) {
    String expression = path.replace(".", "().") + "()";

    if (!Strings.isNullOrEmpty(instance)) {
        expression = instance + "." + expression;
    }//from   www  .  j a  va 2 s . c  o m

    if (!Strings.isNullOrEmpty(prefix)) {
        expression = "\"" + Generator.escape(prefix) + "\" + " + expression;
    }

    if (!Strings.isNullOrEmpty(suffix)) {
        expression += " + \"" + Generator.escape(suffix) + "\"";
    }

    return expression;
}

From source file:org.renjin.maven.PackagePomBuilder.java

public static Model build(PackageDescription description) {
    Model model = new Model();
    model.setModelVersion("4.0.0");
    model.setArtifactId(description.getPackage());
    model.setGroupId("org.r-project.cran");
    model.setVersion(description.getVersion() + "-SNAPSHOT");
    model.setDescription(description.getDescription());
    model.setUrl(description.getUrl());// www .j a  v a2  s  . co m

    if (!Strings.isNullOrEmpty(description.getLicense())) {
        License license = new License();
        license.setName(description.getLicense());
        model.addLicense(license);
    }

    for (Person author : description.getAuthors()) {
        Developer developer = new Developer();
        developer.setName(author.getName());
        developer.setEmail(author.getEmail());
        model.addDeveloper(developer);
    }

    Plugin renjinPlugin = new Plugin();
    renjinPlugin.setGroupId("org.renjin");
    renjinPlugin.setArtifactId("renjin-maven-plugin");
    renjinPlugin.setVersion("0.6.8-SNAPSHOT");

    PluginExecution compileExecution = new PluginExecution();
    compileExecution.setId("renjin-compile");
    compileExecution.addGoal("compile");

    renjinPlugin.addExecution(compileExecution);

    Build build = new Build();
    build.addPlugin(renjinPlugin);

    model.setBuild(build);

    Repository bddRepo = new Repository();
    bddRepo.setId("bedatadriven-public");
    bddRepo.setUrl("http://nexus.bedatadriven.com/content/groups/public");
    bddRepo.setName("bedatadriven Public Repo");
    model.addRepository(bddRepo);

    return model;
}