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:fathom.jcache.JCache.java

@Override
public void start() {
    // add application caches module
    Optional<String> applicationPackage = Optional.fromNullable(settings.getApplicationPackage());
    String fullClassName = ClassUtil.buildClassName(applicationPackage, CACHES_CLASS);
    if (ClassUtil.doesClassExist(fullClassName)) {
        Class<?> moduleClass = ClassUtil.getClass(fullClassName);
        if (CachesModule.class.isAssignableFrom(moduleClass)) {
            CachesModule cachesModule = (CachesModule) ClassUtil.newInstance(moduleClass);
            if (cachesModule != null) {
                log.info("Setting up JCache caches in '{}'", cachesModule.getClass().getName());
                cachesModule.setup(settings, cachingProvider.getCacheManager());
            }/* w  w  w .  j a  v a  2  s . co  m*/
        }
    }
}

From source file:com.googlecode.blaisemath.style.StyleContext.java

public StyleContext(@Nullable StyleContext parent) {
    this.parent = Optional.fromNullable(parent);
}

From source file:fr.obeo.releng.targetplatform.ui.handler.PDEIntegration.java

public PDEIntegration() {
    service = Optional.fromNullable(
            (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class));
}

From source file:org.kaloz.datafeed.processor.app.ProcessorService.java

public Optional<InstrumentPrice> findByProviderAndShortName(InstrumentPriceRequest instrumentPriceRequest) {
    return Optional.fromNullable(instrumentPriceRepository.findByProviderAndShortName(
            instrumentPriceRequest.getProvider(), instrumentPriceRequest.getShortName()));
}

From source file:com.facebook.buck.rules.ProjectConfigBuilder.java

public ProjectConfigBuilder setTestRule(@Nullable BuildRule testRule) {
    arg.testTarget = Optional.fromNullable(testRule);
    return this;
}

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

public ObjectColumnType(@Nullable String objectType, @Nullable List<ColumnDefinition> nestedColumns) {
    super("object");
    this.objectType = Optional.fromNullable(objectType);
    this.nestedColumns = MoreObjects.firstNonNull(nestedColumns, ImmutableList.<ColumnDefinition>of());
}

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

public CreateRepository(String repository, String type, @Nullable GenericProperties genericProperties) {
    this.repository = repository;
    this.type = type;
    this.properties = Optional.fromNullable(genericProperties);
}

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

public CreateSnapshot(QualifiedName name, @Nullable GenericProperties genericProperties) {
    this.name = name;
    this.properties = Optional.fromNullable(genericProperties);
    this.tableList = Optional.absent();

}

From source file:org.ctoolkit.services.endpoints.TransformerHelper.java

/**
 * Converts to <code>Integer</code> value if presented.
 *
 * @param map the map of properties taken from input JSON
 * @param key the JSON property as a key
 * @return the optional <code>Integer</code> value
 *///from  w  w w .j av a2 s.co  m
public static Optional<Integer> toInteger(Map<String, Object> map, String key) {
    checkNotNull(key);
    return Optional.fromNullable((Integer) map.get(key));
}

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

public RestoreSnapshot(QualifiedName name, @Nullable GenericProperties genericProperties) {
    this.name = name;
    this.properties = Optional.fromNullable(genericProperties);
    this.tableList = Optional.absent();

}