List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:org.dswarm.graph.batch.rdf.pnx.utils.NodeTypeUtils.java
public static Optional<NodeType> getNodeType(final Optional<Node> optionalNode, final Optional<Boolean> optionalIsType) { if (!optionalNode.isPresent()) { return Optional.absent(); }/*from ww w. ja v a2 s. co m*/ final NodeType nodeType; final Node node = optionalNode.get(); if (node instanceof Resource) { if (optionalIsType.isPresent()) { if (Boolean.FALSE.equals(optionalIsType.get())) { nodeType = NodeType.Resource; } else { nodeType = NodeType.TypeResource; } } else { nodeType = NodeType.Resource; } } else if (node instanceof BNode) { if (optionalIsType.isPresent()) { if (Boolean.FALSE.equals(optionalIsType.get())) { nodeType = NodeType.BNode; } else { nodeType = NodeType.TypeBNode; } } else { nodeType = NodeType.BNode; } } else if (node instanceof Literal) { nodeType = NodeType.Literal; } else { nodeType = null; } return Optional.fromNullable(nodeType); }
From source file:com.google.gplus.serializer.util.GooglePlusActivityUtil.java
/** * Given a {@link com.google.api.services.plus.model.Person} object and an * {@link org.apache.streams.pojo.json.Activity} object, fill out the appropriate details * * @param item/*from w w w . ja va 2 s .c o m*/ * @param activity * @throws ActivitySerializerException */ public static void updateActivity(Person item, Activity activity) throws ActivitySerializerException { activity.setActor(buildActor(item)); activity.setVerb("update"); activity.setId(formatId(activity.getVerb(), Optional.fromNullable(item.getId()).orNull())); activity.setProvider(getProvider()); activity.setPublished(new DateTime()); }
From source file:eu.bittrade.libs.steemj.plugins.apis.block.models.GetBlockHeaderReturn.java
/** * @return the header */ public Optional<BlockHeader> getHeader() { return Optional.fromNullable(header); }
From source file:com.preferanser.server.dao.objectify.Ofy.java
public <T> Optional<T> get(Class<T> clazz, long id) { Preconditions.checkArgument(id > 0, "Invalid entity id"); return Optional.fromNullable(load().type(clazz).id(id).now()); }
From source file:io.crate.sql.tree.CopyFromStatement.java
public CopyFromStatement(Table table, Expression path, @Nullable GenericProperties genericProperties) { this.table = table; this.path = path; this.genericProperties = Optional.fromNullable(genericProperties); }
From source file:com.google.caliper.runner.config.DeviceConfig.java
/** Returns the value of the option with the given key. */ public final Optional<String> option(String key) { return Optional.fromNullable(options().get(key)); }
From source file:org.gerryai.planning.model.domain.Effect.java
/** * Constructor./*from w w w . j av a 2 s . c o m*/ * @param effect the formula describing the effect */ public Effect(final Formula effect) { this.effect = Optional.fromNullable(effect); }
From source file:org.powerbot.game.api.methods.web.ge.trend.Trend.java
/** * Gets the {@code Trend} enumeration constant for the trend with * the specified name. Note that the specified name must exactly * match the name of a enumeration constant, as returned by the * {@code getName} method. If no constant could be found for * the value, an absent optional instance is returned. * * @param name the name of the trend to retrieve * @return the trend enumeration constant with the specified name; * or an absent optional instance if no such constant exists * @throws NullPointerException if the specified name is {@code null} *///from w w w.j a v a 2 s . c o m public static Optional<Trend> fromName(final String name) { return Optional.fromNullable(MAP_FROM_NAME.get(name)); }
From source file:org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode.java
@Override public final Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) { return Optional.fromNullable(children.get(child)); }
From source file:org.apache.myriad.configuration.MyriadContainerConfiguration.java
public Optional<MyriadDockerConfiguration> getDockerInfo() { return Optional.fromNullable(dockerInfo); }