List of usage examples for java.util Optional of
public static <T> Optional<T> of(T value)
From source file:com.addthis.bundle.util.AutoField.java
default Optional<String> getString(Bundle bundle) { ValueObject valueObject = getValue(bundle); if (valueObject == null) { return Optional.empty(); }//from w ww. j a va2 s. c o m return Optional.of(valueObject.asString().asNative()); }
From source file:com.epam.ta.reportportal.database.entity.item.issue.ExternalSystemType.java
public static Optional<ExternalSystemType> findByName(String name) { for (ExternalSystemType type : ExternalSystemType.values()) { if (type.name().equalsIgnoreCase(name)) { return Optional.of(type); }/* ww w . ja v a 2 s. c o m*/ } return Optional.empty(); }
From source file:com.willwinder.universalgcodesender.connection.ConnectionFactory.java
public static Optional<Connection> getConnection(ConnectionDriver connectionDriver) { if (connectionDriver == ConnectionDriver.JSERIALCOMM) { return Optional.of(new JSerialCommConnection()); } else if (connectionDriver == ConnectionDriver.JSSC) { return Optional.of(new JSSCConnection()); } else if (connectionDriver == ConnectionDriver.TCP) { return Optional.of(new TCPConnection()); }/*from w ww. j a va 2 s . co m*/ return Optional.empty(); }
From source file:com.facebook.buck.util.unarchive.Untar.java
public static Untar gzipUnarchiver() { return new Untar(Optional.of(CompressorStreamFactory.GZIP)); }
From source file:io.github.retz.mesosc.MesosHTTPFetcher.java
public static Optional<String> sandboxDownloadUri(String master, String slaveId, String frameworkId, String executorId, String containerId, String path) { Optional<String> base = sandboxUri("download", master, slaveId, frameworkId, executorId, containerId, RETRY_LIMIT);//from www .j a va2 s .c o m if (base.isPresent()) { try { String encodedPath = URLEncoder.encode(path, UTF_8.toString()); return Optional.of(base.get() + encodedPath); } catch (UnsupportedEncodingException e) { return Optional.empty(); } } return Optional.empty(); }
From source file:am.ik.categolj3.api.git.GitProperties.java
public Optional<UsernamePasswordCredentialsProvider> credentialsProvider() { if (username == null || password == null) { return Optional.empty(); }/*from www. j ava 2 s . c om*/ return Optional.of(new UsernamePasswordCredentialsProvider(username, password)); }
From source file:org.openmhealth.shim.jawbone.mapper.JawboneHeartRateDataPointMapper.java
@Override protected Optional<HeartRate> getMeasure(JsonNode listEntryNode) { Long restingHeartRate = asRequiredLong(listEntryNode, "resting_heartrate"); HeartRate.Builder heartRateBuilder = new HeartRate.Builder(restingHeartRate) .setTemporalRelationshipToPhysicalActivity(AT_REST); setEffectiveTimeFrame(heartRateBuilder, listEntryNode); return Optional.of(heartRateBuilder.build()); }
From source file:ru.mera.samples.infrastructure.aop.BeforeAfterLogAdvice.java
@Before("inImageRepositoryEndpoint()") public void before(JoinPoint joinPoint) { final String[] principals = new String[1]; Optional.of(SecurityContextHolder.getContext()) .ifPresent(securityContext -> Optional.of(securityContext.getAuthentication()) .ifPresent(authentication -> Optional.of(authentication.getPrincipal()) .ifPresent(o -> principals[0] = o.toString()))); logger.info("Before method: " + joinPoint.getSignature().getName() + " by user " + principals); }
From source file:co.runrightfast.component.events.impl.ComponentEventFactoryImpl.java
@Override public ComponentEvent componentEvent(@NonNull final Event event, final String... tags) { final ComponentEventImpl.ComponentEventImplBuilder builder = ComponentEventImpl.builder() .componentId(componentId).event(event); if (ArrayUtils.isNotEmpty(tags)) { return builder.tags(Optional.of(ImmutableSet.copyOf(tags))).build(); }/* w w w. j av a 2 s.com*/ return builder.build(); }