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:org.apache.james.transport.util.ReplyToUtils.java

public static ReplyToUtils from(MailAddress replyTo) {
    return new ReplyToUtils(Optional.fromNullable(replyTo));
}

From source file:org.spongepowered.api.entity.living.meta.SkeletonTypes.java

public static Optional<SkeletonType> valueOf(String name) {
    return Optional.fromNullable(null);
}

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

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

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

    if (file != null && file.exists()) {
        if (file.isFile()) {
            if (StringUtils.endsWithIgnoreCase(FilenameUtils.getBaseName(file.getName()), "dev")) {
                DEV_DEBUG = true;//from   w  w w . j  a  v  a2  s. com
            }
        } else {
            DEV_DEBUG = true;
        }
    } else if (!FMLForgePlugin.RUNTIME_DEOBF) {
        DEV_DEBUG = true;
    }

    if (StringUtils.endsWithIgnoreCase(getCurrent(), "dev")) {
        DEV_DEBUG = true;
    } else if (DEV_DEBUG) {
        FriendlyMobs.metadata.version += "-dev";
    }
}

From source file:org.locationtech.geogig.plumbing.ResolveGeogigURI.java

public static Optional<URI> lookup(final File directory) {
    try {/*from  ww  w  .  java  2  s  .c  o  m*/
        return Optional.fromNullable(lookupGeogigDirectory(directory));
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}

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

public static String getSolrMode(Map<String, String> connectionParameters) {
    return Optional.fromNullable(connectionParameters.get(SolrConnectionParams.MODE)).or("cloud").toLowerCase();
}

From source file:com.googlesource.gerrit.plugins.github.git.GitHubUser.java

private static Optional<String> initEmail(GHUser gitHubUser) throws IOException {
    return Optional.fromNullable(gitHubUser != null ? Strings.emptyToNull(gitHubUser.getEmail()) : null);
}

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

/** WGS84 location, lon/lat axis order */
public Optional<Point> getLocation() {
    return Optional.fromNullable(location);
}

From source file:com.jythonui.server.RUtils.java

private static Optional<String> retrieveS(Object o, String propName) {
    String v = null;/*from ww w .  j  a v a  2s  . c  o m*/
    try {
        v = (String) PropertyUtils.getProperty(o, propName);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        return null;
    }
    return Optional.fromNullable(v);
}

From source file:at.ac.univie.isc.asio.engine.Command.java

/** create a valid command with given arguments */
static Command create(final Multimap<String, String> properties, final List<MediaType> accepted,
        final Principal owner) {
    return new AutoValue_Command(ImmutableMultimap.copyOf(properties), ImmutableList.copyOf(accepted),
            Optional.fromNullable(owner));
}

From source file:springfox.documentation.spring.web.HandlerMethodReturnTypes.java

public static Optional<Class> useType(Class beanType) {
    if (Proxy.class.isAssignableFrom(beanType)) {
        return Optional.absent();
    }/*  w  w  w .j a v a2  s  .c o m*/
    if (Class.class.getName().equals(beanType.getName())) {
        return Optional.absent();
    }
    return Optional.fromNullable(beanType);
}