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:com.treasuredata.client.TDClientHttpConflictException.java

public Optional<String> getConflictsWith() {
    return Optional.fromNullable(conflictsWith);
}

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

public Map<String, Optional<String>> get(Collection<String> keys) {
    Map<String, Optional<String>> values = new HashMap<>();
    for (String key : keys) {
        values.put(key, Optional.fromNullable(conf.values.get(key)));
    }//from ww  w  .  ja v  a 2s  .c  o m
    return values;
}

From source file:org.cloudifysource.cosmo.kvstore.KVStore.java

@Override
public Optional<EntityTagState<String>> getState(URI key) {
    synchronized (store) {

        EntityTagState<String> value = store.get(key);
        return Optional.fromNullable(value);
    }//from   ww  w  .jav a  2 s. c om
}

From source file:io.crate.sql.tree.NamedProperties.java

public NamedProperties(String ident, @Nullable GenericProperties properties) {
    this.ident = ident;
    this.properties = Optional.fromNullable(properties);
}

From source file:com.vmware.photon.controller.apife.db.dao.StepLockDao.java

public Optional<StepLockEntity> findByEntity(String entityId) {
    StepLockEntity result = uniqueResult(namedQuery("StepLock.findByEntity").setString("entityId", entityId));
    return Optional.fromNullable(result);
}

From source file:io.crate.sql.tree.ClusteredBy.java

public ClusteredBy(@Nullable Expression column, @Nullable Expression numberOfShards) {
    this.column = Optional.fromNullable(column);
    this.numberOfShards = Optional.fromNullable(numberOfShards);
}

From source file:se.sics.ktoolbox.util.Either.java

public Optional<L> getOptionalLeft() {
    if (this.isRight()) {
        return Optional.fromNullable(this.getLeft());
    } else {//from   www  .  j  a  v  a  2  s  . co  m
        return Optional.absent();
    }
}

From source file:se.sics.dozy.DozyResult.java

public static DozyResult internalError(String reason) {
    return new DozyResult(Status.INTERNAL_ERROR, Optional.fromNullable(reason));
}

From source file:info.archinnov.achilles.schemabuilder.Drop.java

Drop(String keyspaceName, String tableName) {
    validateNotEmpty(keyspaceName, "Keyspace name");
    validateNotEmpty(tableName, "Table name");
    validateNotKeyWord(keyspaceName, String
            .format("The keyspace name '%s' is not allowed because it is a reserved keyword", keyspaceName));
    validateNotKeyWord(tableName,/*  ww w .j  av a2 s  .  co  m*/
            String.format("The table name '%s' is not allowed because it is a reserved keyword", tableName));
    this.tableName = tableName;
    this.keyspaceName = Optional.fromNullable(keyspaceName);
}

From source file:com.vmware.photon.controller.apife.db.dao.ExtendedAbstractDao.java

public Optional<T> findById(Serializable id) {
    return Optional.fromNullable(get(id));
}