List of usage examples for java.util Optional ofNullable
@SuppressWarnings("unchecked") public static <T> Optional<T> ofNullable(T value)
From source file:io.github.retz.web.JobRequestHandler.java
static void setDriver(SchedulerDriver d) { driver = Optional.ofNullable(d); }
From source file:com.yahoo.elide.parsers.state.RecordTerminalState.java
public RecordTerminalState(PersistentResource record, CollectionTerminalState collectionTerminalState) { this.record = record; this.collectionTerminalState = Optional.ofNullable(collectionTerminalState); }
From source file:com.epam.reportportal.auth.AuthProvidersInfoContributor.java
@Override public void contribute(Info.Builder builder) { Optional<Set<String>> loginDetails = Optional.ofNullable(settingsRepository.findOne("default")) .flatMap(settings -> Optional.ofNullable(settings.getoAuth2LoginDetails())).map(Map::keySet); loginDetails.ifPresent(it -> builder.withDetail("auth_extensions", it)); }
From source file:org.ow2.proactive.connector.iaas.service.KeyPairService.java
public SimpleImmutableEntry<String, String> createKeyPair(String infrastructureId, Instance instance) { return Optional.ofNullable(infrastructureService.getInfrastructure(infrastructureId)) .map(infrastructure -> cloudManager.createKeyPair(infrastructure, instance)) .orElseThrow(() -> new NotFoundException( "infrastructure id : " + infrastructureId + " does not exists")); }
From source file:keywhiz.auth.cookie.CookieAuthenticator.java
@Override public Optional<User> authenticate(Cookie cookie) { User user = null;//w w w.ja v a2s . c o m if (cookie != null) { Optional<UserCookieData> cookieData = getUserCookieData(cookie); if (cookieData.isPresent()) { user = cookieData.get().getUser(); } } return Optional.ofNullable(user); }
From source file:io.dfox.junit.http.api.Path.java
/** * Create a TestPath. If name is all whitespace, empty, or null, an empty Optional will be used. * /*from w ww .j a va2 s . c o m*/ * @param grouping The group the test belongs to. For JUnit tests, this is the test class name. * @param name The name of the test. For JUnit tests, this is the test method name. */ public Path(final String grouping, final String name) { this(grouping, Optional.ofNullable(StringUtils.stripToNull(name))); }
From source file:org.n52.javaps.coding.stream.StreamWriterRepository.java
public <T> Optional<StreamWriter<T>> getWriter(StreamWriterKey key) { @SuppressWarnings("unchecked") StreamWriter<T> writer = (StreamWriter<T>) get(key); return Optional.ofNullable(writer); }
From source file:com.ejisto.util.collector.FieldNode.java
public FieldNode(MockedField element, String path) { this.element = Optional.ofNullable(element); this.path = path; }
From source file:com.ikanow.aleph2.example.flume_harvester.utils.FlumeUtils.java
/** Returns the morphlines config * @param bucket_config//w w w . ja v a 2s .c o m * @return */ public static Optional<String> createMorphlinesConfig(final FlumeBucketConfigBean bucket_config) { //TODO (ALEPH-10): security return Optional.of(Optional.ofNullable(bucket_config.morphlines_config_str())) .map(opt -> opt.map(ss -> ss + "\n").orElse("")) .map(s -> s + Optional.ofNullable(bucket_config.morphlines_config()) .map(o -> _mapper.convertValue(o, JsonNode.class).toString()).orElse("")) .filter(s -> !s.isEmpty()); }
From source file:io.kamax.mxisd.lookup.provider.BridgeFetcher.java
@Override public Optional<SingleLookupReply> find(SingleLookupRequest request) { Optional<String> mediumUrl = Optional.ofNullable(cfg.getMappings().get(request.getType())); if (mediumUrl.isPresent() && !StringUtils.isBlank(mediumUrl.get())) { log.info("Using specific medium bridge lookup URL {}", mediumUrl.get()); return fetcher.find(mediumUrl.get(), request); } else if (!StringUtils.isBlank(cfg.getServer())) { log.info("Using generic bridge lookup URL {}", cfg.getServer()); return fetcher.find(cfg.getServer(), request); } else {//w w w.ja v a 2s . co m log.info("No bridge lookup URL found/configured, skipping"); return Optional.empty(); } }