List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:se.sics.sweep.webservice.toolbox.Result.java
public static Result failed(Status status, String reason) { return new Result(status, Optional.fromNullable(reason), Optional.absent()); }
From source file:org.apache.gobblin.metrics.InnerTimer.java
InnerTimer(MetricContext context, String name, ContextAwareTimer contextAwareTimer) { this.name = name; Optional<MetricContext> parentContext = context.getParent(); if (parentContext.isPresent()) { this.parentTimer = Optional.fromNullable(parentContext.get().contextAwareTimer(name)); } else {//from ww w .ja v a 2 s . c o m this.parentTimer = Optional.absent(); } this.timer = new WeakReference<>(contextAwareTimer); }
From source file:com.vmware.photon.controller.apife.db.dao.ProjectDao.java
public Optional<ProjectEntity> findByName(String name, String parentId) { ProjectEntity result = uniqueResult( namedQuery(findByName).setString("name", name).setString("tenantId", parentId)); return Optional.fromNullable(result); }
From source file:io.crate.sql.tree.FunctionCall.java
public FunctionCall(QualifiedName name, Window window, boolean distinct, List<Expression> arguments) { this.name = name; this.window = Optional.fromNullable(window); this.distinct = distinct; this.arguments = arguments; }
From source file:com.vino.persistence.mongo.MongoPersistor.java
@Override public Optional<EntityKey> getEntityKey(String key) { return Optional.fromNullable(keys.get().findOne(new ObjectId(key)).as(EntityKey.class)); }
From source file:org.spongepowered.api.entity.living.villager.Careers.java
/** * Gets the {@link Profession} with the specified name. * * @param name The name of the profession to return * @return The profession with the given name, if available *//*from ww w . ja v a2s . c om*/ public static Optional<Career> getCareerByName(final String name) { checkArgument(name != null, "Cannot have a null profession name!"); return Optional.fromNullable(null); }
From source file:org.gerryai.planning.model.domain.Precondition.java
/** * Constructor./* w ww. j a v a 2 s .c o m*/ * @param precondition the formula describing the precondition */ public Precondition(final Formula precondition) { this.precondition = Optional.fromNullable(precondition); }
From source file:iterator.util.Utils.java
/** * Concatenates a series of optional elements onto an initial {@link List}. * * <pre>//from w w w . ja va 2s . com * {@code List<Transform> all = concatenate(ifs, selected);} * </pre> * * @param initial the initial {@link List} * @param optional a series of optional elements that may be null * @return a new {@link List} including the non-null optional elements * @see Iterables#concat(Iterable) * @see Optional#asSet() */ @SafeVarargs public static <T> List<T> concatenate(List<T> initial, T... optional) { List<Set<T>> extra = Lists.newArrayList(); for (T nullable : optional) { extra.add(Optional.fromNullable(nullable).asSet()); } Iterable<T> joined = Iterables.concat(initial, Iterables.concat(extra)); return Lists.newArrayList(joined); }
From source file:eu.bittrade.libs.steemj.plugins.apis.chain.models.PushTransactionReturn.java
/** * @return the error */ public Optional<String> getError() { return Optional.fromNullable(error); }
From source file:com.vmware.photon.controller.apife.db.dao.ExtendedAbstractDao.java
public Optional<T> findByName(String name) { T result = uniqueResult(namedQuery(findByName).setString("name", name)); return Optional.fromNullable(result); }