List of usage examples for java.util Optional of
public static <T> Optional<T> of(T value)
From source file:com.github.naoghuman.abclist.model.LinkMappingType.java
public static Optional<LinkMappingType> getType(final String type) { Optional<LinkMappingType> optional = Optional.empty(); for (LinkMappingType value : values()) { if (value.getType().equals(type)) { optional = Optional.of(value); break; }/*from ww w. java 2 s . c om*/ } return optional; }
From source file:com.newtranx.util.reverse_proxy.NginxUtils.java
public static final Optional<String> getRealIp(Function<String, String> headerLoader) { String realIp = headerLoader.apply("X-Real-IP"); String xForwardedFor = headerLoader.apply("X-Forwarded-For"); if (!StringUtils.isEmpty(xForwardedFor)) { int i = xForwardedFor.indexOf(','); if (i > 0) realIp = xForwardedFor.substring(0, i); else/*from w ww . j a va 2 s .com*/ realIp = xForwardedFor.trim(); } return StringUtils.isEmpty(realIp) ? Optional.empty() : Optional.of(realIp); }
From source file:com.palantir.docker.compose.connection.waiting.SuccessOrFailure.java
public static SuccessOrFailure failure(String message) { return ImmutableSuccessOrFailure.of(Optional.of(message)); }
From source file:com.synopsys.integration.blackduck.service.model.BlackDuckQuery.java
public static Optional<BlackDuckQuery> createQuery(final String prefix, final String parameter) { if (StringUtils.isNotBlank(parameter)) { return Optional.of(new BlackDuckQuery(prefix + ":" + parameter)); }// w ww . j a va 2 s . c o m return Optional.empty(); }
From source file:com.ikanow.aleph2.data_import_manager.utils.BeanDiffUtils.java
public static Optional<BucketDiffBean> createDiffBean(final DataBucketBean updated_bucket, final DataBucketBean original_bucket) { return Optional.of(BeanTemplateUtils.build(BucketDiffBean.class) .with(BucketDiffBean::diffs, createDataBucketBeanDiffs(updated_bucket, original_bucket)) .with(BucketDiffBean::lib_diffs, createSharedLibraryDiffs(updated_bucket, original_bucket)).done() .get());//from w w w.j a va 2 s.c o m }
From source file:fi.helsinki.moodi.service.importing.Enrollment.java
public static Enrollment forStudent(final String studentNumber, boolean approved) { return new Enrollment(ROLE_STUDENT, Optional.empty(), Optional.of(studentNumber), null, Optional.empty(), approved);/*from w w w . j a va 2s.c o m*/ }
From source file:org.zalando.riptide.Binding.java
static <A> Binding<A> create(final A attribute, final Executor executor) { return create(Optional.of(attribute), executor); }
From source file:com.spotify.apollo.route.JsonSerializerMiddlewaresTest.java
private static void checkContentType(Response<ByteString> response) { assertThat(response.headers().get("Content-Type"), is(Optional.of("application/json; charset=utf-8"))); }
From source file:com.facebook.buck.testutil.integration.TarInspector.java
/** * readTarZst returns a file name --> contents map for the files contained in 'tar'. * * <p>The returned map is a freshly created one, and changes to the byte[] in it do not affect the * underlying archive./*from w w w . j av a 2 s.c om*/ */ public static ImmutableMap<String, byte[]> readTarZst(Path tar) throws IOException, CompressorException { return readTar(Optional.of(CompressorStreamFactory.ZSTANDARD), tar); }
From source file:fi.helsinki.moodi.service.importing.Enrollment.java
public static Enrollment forTeacher(final String teacherId) { return new Enrollment(ROLE_TEACHER, Optional.of(teacherId), Optional.empty(), null, Optional.empty(), true); }