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

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

Introduction

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

Prototype

public static <T> Optional<T> fromNullable(@Nullable T nullableReference) 

Source Link

Document

If nullableReference is non-null, returns an Optional instance containing that reference; otherwise returns Optional#absent .

Usage

From source file:de.flapdoodle.logparser.streamlistener.OnceAndOnlyOnceStreamListener.java

public Optional<T> value() {
    return Optional.fromNullable(_value);
}

From source file:org.jclouds.rest.internal.GetAcceptHeaders.java

@Override
public Set<String> apply(Invocation invocation) {
    Optional<Consumes> accept = Optional.fromNullable(invocation.getInvokable().getAnnotation(Consumes.class))
            .or(Optional.fromNullable(
                    invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Consumes.class)));
    return (accept.isPresent()) ? ImmutableSet.copyOf(accept.get().value()) : ImmutableSet.<String>of();
}

From source file:com.ngdata.hbaseindexer.util.solr.SolrConnectionParamUtil.java

public static int getSolrMaxConnectionsTotal(Map<String, String> connectionParameters) {
    return Integer.parseInt(
            Optional.fromNullable(connectionParameters.get(SolrConnectionParams.MAX_CONNECTIONS)).or("32"));
}

From source file:org.geogit.storage.memory.Graph.java

/**
 * Looks up a node in the graph by its identifier. 
 */
public Optional<Node> get(ObjectId id) {
    return Optional.fromNullable(nodes.get(id));
}

From source file:com.spotify.heroic.coalesce.CoalesceConfig.java

@JsonCreator
public CoalesceConfig(final List<CoalesceTask> tasks) {
    this.tasks = Optional.fromNullable(tasks).or(ImmutableList::of);
}

From source file:com.streamsets.pipeline.stage.processor.kv.local.LocalStore.java

public Optional<String> get(String key) {
    return Optional.fromNullable(conf.values.get(key));
}

From source file:io.github.robwin.swagger2markup.utils.TagUtils.java

/**
 * Retrieves the optional description of a tag.
 *
 * @param tagsMap the Map of tags//from  w  w  w .  j a  v  a2 s . c  o m
 * @param tagName the name of the tag
 * @return the optional description of the tag
 */
public static Optional<String> getTagDescription(Map<String, Tag> tagsMap, String tagName) {
    Tag tag = tagsMap.get(tagName);
    if (tag != null) {
        return Optional.fromNullable(tag.getDescription());
    }
    return Optional.absent();
}

From source file:fathom.quartz.QuartzModule.java

@Override
protected void setup() {
    Optional<String> applicationPackage = Optional.fromNullable(getSettings().getApplicationPackage());
    String fullClassName = ClassUtil.buildClassName(applicationPackage, JOBS_CLASS);
    if (ClassUtil.doesClassExist(fullClassName)) {
        Class<?> moduleClass = ClassUtil.getClass(fullClassName);
        if (JobsModule.class.isAssignableFrom(moduleClass)) {
            JobsModule jobsModule = (JobsModule) ClassUtil.newInstance(moduleClass);
            if (jobsModule != null) {

                log.info("Scheduling Quartz jobs in '{}'", jobsModule.getClass().getName());
                install(jobsModule);/*  w  w w  .  ja v  a2s  .  co  m*/

                bind(Quartz.class);
            }
        }
    }
}

From source file:com.pingcap.tikv.PDMockServer.java

public void addGetMemberResp(GetMembersResponse r) {
    getMembersResp.addLast(Optional.fromNullable(r));
}

From source file:org.geogig.osm.internal.history.Change.java

public Optional<Node> getNode() {
    return Optional.fromNullable(node);
}