List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:org.basepom.mojo.propertyhelper.beans.MacroDefinition.java
public Optional<String> getMacroType() { return Optional.fromNullable(macroType); }
From source file:io.macgyver.core.resource.ResourceProvider.java
public Optional<Resource> findResourceByPath(String path) throws IOException { try {/*from www. ja v a 2 s .c o m*/ return Optional.fromNullable(getResourceByPath(path)); } catch (IOException e) { } return Optional.absent(); }
From source file:io.crate.sql.tree.Delete.java
public Delete(Relation relation, @Nullable Expression where) { Preconditions.checkNotNull(relation, "relation is null"); this.relation = relation; this.where = Optional.fromNullable(where); }
From source file:com.facebook.buck.rules.FakeOnDiskBuildInfo.java
@Override public Optional<RuleKey> getRuleKey() { return Optional.fromNullable(ruleKey); }
From source file:io.crate.sql.tree.ShowTables.java
public ShowTables(@Nullable QualifiedName schema, @Nullable String likePattern, @Nullable Expression whereExpression) { this.schema = Optional.fromNullable(schema); this.whereExpression = Optional.fromNullable(whereExpression); this.likePattern = Optional.fromNullable(likePattern); }
From source file:org.apache.aurora.scheduler.storage.db.DbQuotaStore.java
@Timed("quota_store_fetch_quota") @Override//ww w. j a v a 2 s .c o m public Optional<IResourceAggregate> fetchQuota(String role) { return Optional.fromNullable(mapper.select(role)).transform(DBResourceAggregate::toImmutable); }
From source file:com.tinspx.util.base.Base.java
/** * Attempts to parse the integer if is an Integer, Number, or CharSequence *//* w w w . ja v a 2 s . c om*/ public static Optional<Integer> parseInt(@Nullable Object o) { if (o instanceof Integer) { return Optional.of((Integer) o); } else if (o instanceof Number) { return Optional.of(((Number) o).intValue()); } else if (o instanceof CharSequence) { return Optional.fromNullable(Ints.tryParse(o.toString())); } else { return Optional.absent(); } }
From source file:im.dadoo.teak.biz.bo.impl.DefaultPageBO.java
@Override public Optional<PagePO> insert(String name, String title, String author, String html) { long publishDatetime = System.currentTimeMillis(); int click = 0; String text = Jsoup.parse(html).text(); PagePO pagePO = new PagePO(); pagePO.setName(name);//w ww. ja v a 2 s. c o m pagePO.setTitle(title); pagePO.setAuthor(author); pagePO.setHtml(html); pagePO.setText(text); pagePO.setPublishDatetime(publishDatetime); pagePO.setClick(click); return Optional.fromNullable(this.pageDAO.insert(pagePO)); }
From source file:com.github.autermann.wps.commons.description.input.BoundingBoxInputDescription.java
protected BoundingBoxInputDescription(Builder<?, ?> builder) { super(builder); this.supportedCRS = builder.getSupportedCRS().build(); this.defaultCRS = Optional.fromNullable(builder.getDefaultCRS()); }
From source file:se.sics.ktoolbox.util.aggregation.AggregationLevelOption.java
@Override public Optional<AggregationLevel> readValue(Config config) { Optional aggLevelOpt = config.readValue(name); if (aggLevelOpt.isPresent()) { if (aggLevelOpt.get() instanceof String) { AggregationLevel aggLevel = AggregationLevel.create((String) aggLevelOpt.get()); return Optional.fromNullable(aggLevel); } else if (aggLevelOpt.get() instanceof AggregationLevel) { return aggLevelOpt; }//w ww . j a v a2s .c om } return Optional.absent(); }