List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:me.lazerka.gae.jersey.oauth2.facebook.FacebookUserPrincipal.java
public Optional<DebugTokenResponse> getDebugTokenResponse() { return Optional.fromNullable(debugTokenResponse); }
From source file:models.petstore.ApiKeyHeader.java
@Override public String getDefaultValue() { Context context = RouteDispatcher.getRouteContext(); if (context == null) { // no context because we are generated a Swagger specification return DEFAULT; }/*from w ww . j a v a 2s. c om*/ // return the primary account token or DEFAULT Account account = new AuthExtractor().extract(context); return Optional.fromNullable(account.getToken()).or(DEFAULT); }
From source file:com.vmware.photon.controller.apife.db.dao.VmDao.java
public Optional<VmEntity> findByName(String name, ProjectEntity parent) { VmEntity result = uniqueResult(/*from w w w . j a va 2 s . c om*/ namedQuery(findByName).setString("name", name).setString("projectId", parent.getId())); return Optional.fromNullable(result); }
From source file:io.crate.planner.node.dml.CopyTo.java
public CopyTo(UUID id, Plan innerPlan, @Nullable MergePhase handlerMergeNode) { this.id = id; this.innerPlan = innerPlan; this.handlerMergeNode = Optional.fromNullable(handlerMergeNode); }
From source file:com.cloudera.exhibit.server.jdbi.JdbiExhibitStore.java
@Override public Optional<Exhibit> find(String id) { return Optional.fromNullable(exhibits.get(id)); }
From source file:com.spotify.helios.agent.KafkaClientProvider.java
public KafkaClientProvider(@Nullable final List<String> brokerList) { partialConfigs = Optional.fromNullable(brokerList) .transform(new Function<List<String>, ImmutableMap<String, Object>>() { @Nullable//from w w w . j a va 2 s .co m @Override public ImmutableMap<String, Object> apply(List<String> input) { return ImmutableMap.<String, Object>of("bootstrap.servers", Joiner.on(',').join(input), "acks", KAFKA_QUORUM_PARAMETER, "client.id", KAFKA_HELIOS_CLIENT_ID, "metadata.fetch.timeout.ms", 5000); } }); }
From source file:org.locationtech.geogig.api.plumbing.diff.DefaultGeometryDiffImpl.java
private CharSequence geometryValueAsString(Optional<Geometry> value) { return TextValueSerializer.asString(Optional.fromNullable((Object) value.orNull())); }
From source file:org.locationtech.geogig.model.impl.RevPersonImpl.java
/** * @return the email */ @Override public Optional<String> getEmail() { return Optional.fromNullable(email); }
From source file:com.facebook.buck.rules.ProjectConfigBuilder.java
public ProjectConfigBuilder setTestRoots(@Nullable ImmutableList<String> testRoots) { arg.testRoots = Optional.fromNullable(testRoots); return this; }
From source file:com.citytechinc.cq.clientlibs.core.listeners.components.factory.impl.DefaultDependentComponentEventFactory.java
@Override public Optional<DependentComponentEvent> make(Event event, Map<String, DependentComponent> dependentComponentByPathMap, Session session) throws RepositoryException { switch (event.getType()) { case Event.NODE_ADDED: return Optional.fromNullable(makeForNodeAddedEvent(event, session.getNode(event.getPath()))); case Event.NODE_MOVED: return Optional.fromNullable(makeForNodeMovedEvent(event, session.getNode(event.getPath()))); case Event.NODE_REMOVED: return Optional.fromNullable(makeForNodeRemovedEvent(event, dependentComponentByPathMap)); case Event.PROPERTY_ADDED: return Optional.fromNullable(makeForPropertyAddedEvent(event, session.getProperty(event.getPath()))); case Event.PROPERTY_CHANGED: return Optional.fromNullable(makeForPropertyChangedEvent(event, session.getProperty(event.getPath()))); case Event.PROPERTY_REMOVED: return Optional.fromNullable(makeForPropertyRemovedEvent(event, dependentComponentByPathMap)); case Event.PERSIST: return Optional.of(makeForPersistEvent()); default:// w w w . jav a 2 s . c o m return Optional.absent(); } }