List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:com.github.nbyl.xfdcontrol.service.jenkins.StatusRouteService.java
@PostConstruct public void startStatusRoute() throws Exception { Optional<Route> oldRoute = Optional.fromNullable(camelContext.getRoute(ROUTE_NAME)); if (oldRoute.isPresent()) { camelContext.stopRoute(ROUTE_NAME); camelContext.removeRoute(ROUTE_NAME); }//from w ww.j a v a 2 s . com camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("timer://statusUpdate?fixedRate=true&delay=0&period=10000") .to(settings.getJobUrl() + "/api/json").unmarshal() .json(JsonLibrary.Gson, JenkinsJobStatus.class).convertBodyTo(JenkinsJobStatusEvent.class) .to("spring-event://default").routeId(ROUTE_NAME); } }); }
From source file:org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement.java
public AttributeConfigElement(Object defaultValue, Object value, final EditStrategyType editStrategyType) { this.defaultValue = defaultValue; this.value = value; this.editStrategy = Optional.fromNullable(editStrategyType); }
From source file:org.opendaylight.yangtools.yang.data.api.schema.tree.spi.LazyMutableContainerNode.java
@Override public Optional<TreeNode> getChild(final PathArgument childId) { final TreeNode modified = getModifiedChild(childId); if (modified != null) { return Optional.of(modified); }/*from ww w.j av a 2 s .co m*/ return Optional.fromNullable(AbstractContainerNode.getChildFromData(getData(), childId, getVersion())); }
From source file:org.raml.jaxrs.parser.model.JerseyJaxRsFormParameter.java
@Override public Optional<String> getDefaultValue() { return Optional.fromNullable(this.parameter.getDefaultValue()); }
From source file:adept.common.TemporalSpan.java
private TemporalSpan(TemporalValue beginDate, TemporalValue endDate) { this.beginDate = Optional.fromNullable(beginDate); this.endDate = Optional.fromNullable(endDate); }
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 . co m 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:org.apache.aurora.scheduler.storage.db.DbSchedulerStore.java
@Timed("scheduler_store_fetch_framework_id") @Override public Optional<String> fetchFrameworkId() { return Optional.fromNullable(mapper.select()); }
From source file:io.dohko.jdbi.OptionalContainerFactory.java
@Override public ContainerBuilder<Optional<?>> newContainerBuilderFor(Class<?> type) { return new ContainerBuilder<Optional<?>>() { private Optional<?> _optional = Optional.absent(); @Override/*w ww .j a v a2 s .com*/ public ContainerBuilder<Optional<?>> add(Object it) { this._optional = Optional.fromNullable(it); return this; } @Override public Optional<?> build() { return _optional; } }; }
From source file:eu.numberfour.n4js.ui.workingsets.WorkingSetEditWizard.java
/** * Returns with the edited working set if it was initialized from the actual selection. * * @return the edited working set. Could be {@link Optional#absent() absent}. *//*from w ww . j av a 2s . c om*/ protected Optional<WorkingSet> getEditedWorkingSet() { return Optional.fromNullable(editedWorkingSet); }
From source file:com.github.autermann.matlab.server.MatlabInstanceConfiguration.java
public Optional<File> getBaseDir() { return Optional.fromNullable(this.baseDir); }