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:io.mesosphere.mesos.frameworks.cassandra.ZooKeeperSeedProviderConfig.java

private static Optional<String> optionalString(String key, Map<String, String> parameters) {
    return Optional.fromNullable(parameters.get(key));
}

From source file:org.retrostore.android.net.DataFetcher.java

public static Optional<DataFetcher> get() {
    // Might be null if the app got cleaned up but the details activity was resumed.
    return Optional.fromNullable(sInstance);
}

From source file:org.geogit.web.SingleRepositoryProvider.java

@Override
public Optional<GeoGIT> getGeogit(Request request) {
    return Optional.fromNullable(geogit);
}

From source file:com.almuradev.guide.content.PageRegistry.java

public static Optional<Page> getPage(String identifier) {
    return Optional.fromNullable(PAGES.get(identifier));
}

From source file:com.shufudong.GuavaExample.collect.OptionalExample.java

/**
 * @param object//from  ww  w  . j  a v a  2  s  .  co m
 * @return
 * @category fromNullable?object??
 * ,?fromNullable???
 * @throw
 */
public static Object fromNullable(Object object) {
    return Optional.fromNullable(object).or("?object,??.");
}

From source file:org.onos.yangtools.yang.data.impl.codec.EnumStringCodec.java

static TypeDefinitionAwareCodec<?, EnumTypeDefinition> from(final EnumTypeDefinition normalizedType) {
    return new EnumStringCodec(Optional.fromNullable(normalizedType));
}

From source file:org.onos.yangtools.yang.data.impl.codec.BooleanStringCodec.java

static TypeDefinitionAwareCodec<?, BooleanTypeDefinition> from(final BooleanTypeDefinition normalizedType) {
    return new BooleanStringCodec(Optional.fromNullable(normalizedType));
}

From source file:google.registry.request.auth.AuthResult.java

static AuthResult create(AuthLevel authLevel, @Nullable UserAuthInfo userAuthInfo) {
    if (authLevel == AuthLevel.USER) {
        checkNotNull(userAuthInfo);/*from  ww  w  .  java  2  s .  com*/
    }
    return new AutoValue_AuthResult(authLevel, Optional.fromNullable(userAuthInfo));
}

From source file:com.kegare.frozenland.util.Version.java

private static void initialize() {
    CURRENT = Optional.of(Strings.nullToEmpty(Frozenland.metadata.version));
    LATEST = Optional.fromNullable(CURRENT.orNull());

    File file = FrozenUtils.getModContainer().getSource();

    if (file != null && file.exists()) {
        if (file.isFile()) {
            String name = FilenameUtils.getBaseName(file.getName());

            if (StringUtils.endsWithIgnoreCase(name, "dev")) {
                DEV_DEBUG = true;//from   w w  w . j  av a2  s .c  o  m
            }
        } else if (file.isDirectory()) {
            DEV_DEBUG = true;
        }
    } else if (!FMLForgePlugin.RUNTIME_DEOBF) {
        DEV_DEBUG = true;
    }

    if (Frozenland.metadata.version.endsWith("dev")) {
        DEV_DEBUG = true;
    } else if (DEV_DEBUG) {
        Frozenland.metadata.version += "-dev";
    }
}

From source file:org.opendaylight.yangtools.yang.data.operations.DataOperations.java

public static Optional<ContainerNode> modify(ContainerSchemaNode schema, ContainerNode stored,
        ContainerNode modified, ModifyAction defaultOperation) throws DataModificationException {

    OperationStack operations = new OperationStack(defaultOperation);

    return new ContainerNodeModification().modify(schema, Optional.fromNullable(stored),
            Optional.fromNullable(modified), operations);
}