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:springfox.documentation.service.Tags.java

public static Function<String, String> descriptor(final Map<String, Tag> tagLookup,
        final String defaultDescription) {

    return new Function<String, String>() {
        @Override//from   ww  w  . ja  v a 2s  .  c o  m
        public String apply(String input) {
            return Optional.fromNullable(tagLookup.get(input)).transform(toTagDescription())
                    .or(defaultDescription);
        }
    };
}

From source file:it.f2informatica.core.services.UserServiceImpl.java

@Override
public Optional<UserModel> findUserById(String userId) {
    return Optional.fromNullable(userRepositoryGateway.findUserById(userId));
}

From source file:com.github.mmichaelis.hamcrest.nextdeed.concurrent.ThrowAssertionError.java

@Override
public R apply(@Nullable WaitTimeoutEvent<T, R> input) {
    assert input != null : "null values unexpected";
    R lastResult = input.getLastResult();
    assertThat(Optional.fromNullable(reason).or(""), lastResult, matcher);
    // Will never get here unless as last validation the actual value eventually matches,
    // which actually means that the matcher responds differently on the same value.
    return lastResult;
}

From source file:com.opower.rest.client.generator.extractors.DefaultClientErrorHandler.java

public DefaultClientErrorHandler(List<ClientErrorInterceptor> interceptors) {
    this.interceptors = Optional.fromNullable(interceptors).or(new ArrayList<ClientErrorInterceptor>());
}

From source file:org.grycap.gpf4med.model.util.Value.java

public void setValue(final String value) {
    this.value = Optional.fromNullable(value);
}

From source file:org.locationtech.geogig.model.impl.RevPersonImpl.java

/**
 * @return the name
 */
@Override
public Optional<String> getName() {
    return Optional.fromNullable(name);
}

From source file:springfox.documentation.spi.schema.contexts.ModelPropertyContext.java

public ModelPropertyContext(ModelPropertyBuilder builder, AnnotatedElement annotatedElement,
        TypeResolver resolver, DocumentationType documentationType) {

    this.builder = builder;
    this.resolver = resolver;
    this.annotatedElement = Optional.fromNullable(annotatedElement);
    this.beanPropertyDefinition = Optional.absent();
    this.documentationType = documentationType;
}

From source file:org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfServerMonitoringModule.java

@Override
public java.lang.AutoCloseable createInstance() {
    return new NetconfMonitoringServiceImpl(getAggregatorDependency(),
            Optional.fromNullable(getScheduledThreadpoolDependency()), getMonitoringUpdateInterval());
}

From source file:org.apache.aurora.scheduler.storage.mem.MemLockStore.java

@Override
public Optional<ILock> fetchLock(ILockKey lockKey) {
    return Optional.fromNullable(locks.get(lockKey));
}

From source file:me.lazerka.gae.jersey.oauth2.facebook.FacebookUserPrincipal.java

public Optional<AccessTokenResponse> getAccessTokenResponse() {
    return Optional.fromNullable(accessTokenResponse);
}