Example usage for com.google.common.base Optional or

List of usage examples for com.google.common.base Optional or

Introduction

In this page you can find the example usage for com.google.common.base Optional or.

Prototype

@Beta
public abstract T or(Supplier<? extends T> supplier);

Source Link

Document

Returns the contained instance if it is present; supplier.get() otherwise.

Usage

From source file:internal.msm.spikes.dw.server.HelloWorldTemplate.java

public String render(Optional<String> name) {
    return format(content, name.or(defaultName));
}

From source file:la.alsocan.symbiot.api.resources.PingResource.java

@GET
public Ping ping(@QueryParam("echo") Optional<String> echo) {
    return new Ping(echo.or(defaultEcho));
}

From source file:com.mycompany.httpserverclient.AppResource.java

@GET
@Timed/*from  w  ww .  ja  v  a2 s .  c  o m*/
public Saying sayHello(@QueryParam("name") Optional<String> name) {
    final String value = String.format(template, name.or(defaultName));
    return new Saying(counter.incrementAndGet(), value);
}

From source file:org.apache.gobblin.config.store.hdfs.SimpleHDFSConfigStoreFactory.java

@Override
protected URI getDefaultRootDir(Config factoryConfig, FileSystem defaultFileSystem,
        Optional<URI> configDefinedDefaultURI) {
    return configDefinedDefaultURI.or(defaultFileSystem.getHomeDirectory().toUri());
}

From source file:no.tiasg.cvgen.client.resource.GeneratorResource.java

@GET
@Timed/*from w w w  .java  2  s .c  om*/
public String getCV(@QueryParam("firstName") Optional<String> name) {
    //        return new CV();
    return "Hello " + name.or("Stranger");
}

From source file:be.rufer.playground.dropwizard.resource.ExampleResource.java

@GET
@Timed/*from   w  ww .ja  va 2s.  c o  m*/
public ResponseWrapper getExample(@QueryParam("name") Optional<String> name) {
    final String value = String.format(template, name.or(defaultName));
    return new ResponseWrapper(counter.incrementAndGet(), value);
}

From source file:org.glassfish.jersey.tests.integration.jersey2612.Resource.java

@Path("hello")
@GET/*from   w w w . j  av a  2  s.co m*/
@Produces("text/plain")
public String hello(@QueryParam("name") final Optional<String> name) {
    return "Hello " + name.or("World") + "!";
}

From source file:org.edeoliveira.oauth2.dropwizard.resources.HelloResource.java

@GET
@Timed// w w w .ja v a  2 s .  co m
@Path(value = "/test")
public Saying sayHelloToUnauthenticatedUser(@QueryParam("name") Optional<String> name) {
    final String value = String.format(template, name.or(defaultName));
    return new Saying(counter.incrementAndGet(), value);
}

From source file:com.moai.app.example.helloworld.resources.HelloWorldResource.java

@GET
@Timed//from  ww  w . ja  v  a  2 s . co m
public Saying sayHello(@QueryParam("name") Optional<String> name) {
    return new Saying(counter.incrementAndGet(), String.format(template, name.or(defaultName)));
}

From source file:org.geogit.remote.HttpRepositoryWrapper.java

/**
 * Gets the depth of the given commit.//from w w w.ja  va2  s  . co m
 * 
 * @param commitId the commit id
 * @return the depth, or 0 if the commit was not found
 */
@Override
public int getDepth(ObjectId commitId) {
    Optional<Integer> depth = HttpUtils.getDepth(repositoryURL, commitId.toString());

    return depth.or(0);
}