Example usage for com.google.common.base Optional absent

List of usage examples for com.google.common.base Optional absent

Introduction

In this page you can find the example usage for com.google.common.base Optional absent.

Prototype

public static <T> Optional<T> absent() 

Source Link

Document

Returns an Optional instance with no contained reference.

Usage

From source file:org.dswarm.graph.delta.match.model.util.CSEntityUtil.java

public static Optional<? extends Collection<ValueEntity>> getValueEntities(
        final Optional<? extends Collection<CSEntity>> csEntities) {

    if (!csEntities.isPresent() || csEntities.get().isEmpty()) {

        return Optional.absent();
    }/* w  w  w  . j a  v  a2  s  . c o m*/

    final Set<ValueEntity> valueEntities = new HashSet<>();

    for (final CSEntity csEntity : csEntities.get()) {

        valueEntities.addAll(csEntity.getValueEntities());
    }

    return Optional.of(valueEntities);
}

From source file:org.dswarm.graph.gdm.utils.NodeTypeUtils.java

public static Optional<NodeType> getNodeType(final Optional<Node> optionalNode,
        final Optional<Boolean> optionalIsType) {

    if (!optionalNode.isPresent()) {

        return Optional.absent();
    }/*from  w w  w .java 2  s. c o m*/

    return getNodeTypeByGDMNodeType(Optional.of(optionalNode.get().getType()), optionalIsType);
}

From source file:com.google.errorprone.ErrorProneVersion.java

/**
 * Loads the Error Prone version.//  www .  j a  v  a 2  s  . com
 *
 * <p>This depends on the Maven build, and will always return {@code Optional.absent()} with
 * other build systems.
 */
public static Optional<String> loadVersionFromPom() {
    try (InputStream stream = ErrorProneVersion.class.getResourceAsStream(PROPERTIES_RESOURCE)) {
        if (stream == null) {
            return Optional.absent();
        }
        Properties mavenProperties = new Properties();
        mavenProperties.load(stream);
        return Optional.of(mavenProperties.getProperty("version"));
    } catch (IOException expected) {
        return Optional.absent();
    }
}

From source file:org.geogit.di.PluginDefaults.java

public PluginDefaults() {
    refs = objects = staging = graph = Optional.absent();
}

From source file:com.ayuget.redface.util.UserUtils.java

/**
 * Ugly method to fetch a user id from stored cookies
 *//* www  .  j  a v a 2  s.c om*/
public static Optional<Integer> getLoggedInUserId(User user, OkHttpClient httpClient) {
    CookieManager cookieManager = (CookieManager) httpClient.getCookieHandler();
    CookieStore cookieStore = cookieManager.getCookieStore();
    for (HttpCookie cookie : cookieStore.getCookies()) {
        if (cookie.getName().equals("md_id")) {
            return Optional.of(Integer.valueOf(cookie.getValue()));
        }
    }

    return Optional.absent();
}

From source file:org.dswarm.graph.rdf.utils.NodeTypeUtils.java

public static Optional<NodeType> getNodeType(final Optional<RDFNode> optionalNode,
        final Optional<Boolean> optionalIsType) {

    if (!optionalNode.isPresent()) {

        return Optional.absent();
    }/*from   w w  w  .  j  a  v  a 2  s.  c  om*/

    final NodeType nodeType;
    final RDFNode node = optionalNode.get();

    if (node.isURIResource()) {

        if (optionalIsType.isPresent()) {

            if (Boolean.FALSE.equals(optionalIsType.get())) {

                nodeType = NodeType.Resource;
            } else {

                nodeType = NodeType.TypeResource;
            }
        } else {

            nodeType = NodeType.Resource;
        }
    } else if (node.isAnon()) {

        if (optionalIsType.isPresent()) {

            if (Boolean.FALSE.equals(optionalIsType.get())) {

                nodeType = NodeType.BNode;
            } else {

                nodeType = NodeType.TypeBNode;
            }
        } else {

            nodeType = NodeType.BNode;
        }
    } else if (node.isLiteral()) {

        nodeType = NodeType.Literal;
    } else {

        nodeType = null;
    }

    return Optional.fromNullable(nodeType);
}

From source file:com.github.radium226.common.Either.java

public static <L, R> Either<L, R> right(R right) {
    return new Either(Optional.absent(), Optional.of(right));
}

From source file:com.google.javascript.jscomp.JsCheckerHelper.java

static Optional<String> convertPathToModuleName(String path, Iterable<String> roots) {
    checkArgument(!path.startsWith("/"));
    if (!path.endsWith(".js") && !path.endsWith(".zip")) {
        return Optional.absent();
    }// ww  w . j a v  a  2s  .co  m
    String module = path;
    for (String root : roots) {
        if (module.startsWith(root + "/")) {
            module = module.substring(root.length() + 1);
            break;
        }
    }

    String moduleOrZipName = module.split("!")[0];
    return Optional.of("/" + moduleOrZipName);
}

From source file:dagger2.internal.codegen.InjectionAnnotations.java

static Optional<AnnotationMirror> getScopeAnnotation(Element e) {
    checkNotNull(e);/*w ww . j a v  a2  s.c o  m*/
    ImmutableSet<? extends AnnotationMirror> scopeAnnotations = getScopes(e);
    switch (scopeAnnotations.size()) {
    case 0:
        return Optional.absent();
    case 1:
        return Optional.<AnnotationMirror>of(scopeAnnotations.iterator().next());
    default:
        throw new IllegalArgumentException(e + " was annotated with more than one @Scope annotation");
    }
}

From source file:com.empcraft.xpbank.util.ChunkUtil.java

public static Optional<Chunk> getLoadedChunk(World world, Location loc) {
    Preconditions.checkNotNull(loc);//from   w w  w.  j  a v a2 s  .  c  om
    Optional<Chunk> loadedChunk = Optional.absent();

    final Chunk chunkAt = world.getChunkAt(loc);
    if (chunkAt.isLoaded()) {
        loadedChunk = Optional.of(chunkAt);
    }

    return loadedChunk;
}