List of usage examples for java.util Optional ofNullable
@SuppressWarnings("unchecked") public static <T> Optional<T> ofNullable(T value)
From source file:org.dswarm.graph.resources.GraphResource.java
protected Optional<Integer> getIntValue(final String key, final JsonNode json) { final JsonNode node = json.get(key); final Optional<Integer> optionalValue; if (node != null) { optionalValue = Optional.ofNullable(node.asInt()); } else {/* w ww . jav a 2 s . co m*/ optionalValue = Optional.empty(); } return optionalValue; }
From source file:com.example.app.profile.model.terminology.FallbackProfileTermProvider.java
@Override public TextSource companies() { return isBlank( Optional.ofNullable(getProfileTermProvider()).map(ProfileTermProvider::companies).orElse(null)) ? _defaultProfileTermProvider.companies() : getProfileTermProvider().companies(); }
From source file:org.openlmis.fulfillment.service.request.RequestParameters.java
/** * Set parameter (key argument) with the value only if the value is not null. *//*from w w w . j a v a 2 s .c o m*/ public RequestParameters set(String key, Collection<?> valueCollection) { Optional.ofNullable(valueCollection).orElse(Collections.emptyList()).forEach(elem -> set(key, elem)); return this; }
From source file:io.gravitee.repository.couchbase.management.CouchbaseEventRepository.java
@Override public Optional<Event> findById(String id) throws TechnicalException { logger.debug("Find event by ID [{}]", id); EventCouchbase event = internalEventRepo.findOne(id); Event res = mapper.map(event, Event.class); logger.debug("Find event by ID [{}] - Done", id); return Optional.ofNullable(res); }
From source file:io.gravitee.repository.jdbc.JdbcApiKeyRepository.java
public Optional<ApiKey> retrieve(String apiKey) throws TechnicalException { return Optional.ofNullable(apiKeyJpaConverter.convertTo(internalJpaApiKeyRepository.findOne(apiKey))); }
From source file:com.kazuki43zoo.jpetstore.service.CatalogService.java
public List<Product> searchProductList(String keywords) { return Stream.of(Optional.ofNullable(keywords).orElse("").split("\\s+")).distinct() .flatMap(x -> productMapper.selectProductList(x).stream()).distinct().collect(Collectors.toList()); }
From source file:fi.helsinki.opintoni.integration.coursepage.CoursePageRestClient.java
@Cacheable(CacheConstants.COURSE_PAGE_ONE_OFF_EVENTS) public List<CoursePageEvent> getEvents(String courseImplementationId) { ResponseEntity<List<CoursePageEvent>> responseEntity = restTemplate.exchange( "{baseUrl}/events?course_implementation_id={courseImplementationId}", HttpMethod.GET, null, new ParameterizedTypeReference<List<CoursePageEvent>>() { }, baseUrl, courseImplementationId); return Optional.ofNullable(responseEntity.getBody()).orElse(newArrayList()); }
From source file:com.orange.cloud.servicebroker.filter.core.filters.ServiceInstanceBindingFilterRunner.java
/** * Run all filters that should be processed before a service instance instance binding has been created. * * @param request details of a request to bind to a service instance binding. *///from w w w . j av a 2 s .c o m public void preBind(CreateServiceInstanceBindingRequest request) { Optional.ofNullable(createServiceInstanceBindingPreFilters) .ifPresent(serviceBrokerFilters -> serviceBrokerFilters.forEach(filter -> filter.run(request))); }
From source file:no.ssb.jsonstat.v2.Dimension.java
public Optional<String> getLabel() { // "label content should be written in lowercase except when it is a dataset label" return Optional.ofNullable(label).map(String::toLowerCase); }
From source file:io.github.carlomicieli.footballdb.starter.parsers.DraftParser.java
protected Optional<Element> picksTable(Document doc) { return Optional.ofNullable(doc.getElementById("drafts")); }