List of usage examples for java.util Optional of
public static <T> Optional<T> of(T value)
From source file:com.devicehive.dao.rdbms.IdentityProviderDaoRdbmsImpl.java
@Override public boolean deleteById(@NotNull String id) { return createNamedQuery("IdentityProvider.deleteByName", Optional.of(CacheConfig.bypass())) .setParameter("name", id).executeUpdate() > 0; }
From source file:net.sourceforge.fullsync.cli.CliRuntimeConfiguration.java
private Optional<String> parseProfileToRun(CommandLine args) { if (args.hasOption('r')) { return Optional.of(args.getOptionValue('r')); }//from w ww . j ava 2s .com return Optional.empty(); }
From source file:io.maxthomas.dictum.lid.ValidISO3Languages.java
/** * * @param abbr/*from w w w. ja va 2s .co m*/ * a {@link String} representing a possible ISO3 abbreviation * @return {@link Optional#empty()} if not present, otherwise, an * {@link Optional} {@link String} wrapping the value */ public static final Optional<String> getName(final String abbr) { return isValidISO3Abbreviation(abbr) ? Optional.of(iso3AbbrNameMap.get(abbr)) : Optional.empty(); }
From source file:fi.helsinki.opintoni.service.CourseServiceTest.java
@Test public void thatStudentCourseDtosAreFetched() { expectStudentCourses();// w w w. j a va 2 s . com Set<CourseDto> courseDtos = courseService.getCourses(Optional.of(TestConstants.STUDENT_NUMBER), Optional.empty(), Locale.ENGLISH); assertThat(courseDtos).hasSize(1); assertThat(courseDtos, hasCourseWithRealisationId(TestConstants.STUDENT_COURSE_REALISATION_ID)); assertThat(courseDtos.iterator().next().teachers.get(0)).isEqualTo("Rantala Kari A"); }
From source file:alfio.manager.support.FeeCalculator.java
public static BiFunction<Integer, Long, Optional<Long>> getCalculator(Event event, ConfigurationManager configurationManager) { return (numTickets, amountInCent) -> { if (isPlatformModeEnabled(event, configurationManager)) { String feeAsString = configurationManager.getStringConfigValue( Configuration.from(event.getOrganizationId(), event.getId(), PLATFORM_FEE), "0"); String minimumFee = configurationManager.getStringConfigValue( Configuration.from(event.getOrganizationId(), event.getId(), PLATFORM_MINIMUM_FEE), "0"); return Optional.of(new FeeCalculator(feeAsString, minimumFee, numTickets).calculate(amountInCent)); }// w ww. j a va2 s. co m return Optional.empty(); }; }
From source file:de.se_rwth.langeditor.util.Misc.java
public static Optional<Image> loadImage(String location) { try {/*from w w w . j av a 2s .com*/ URL url = new URL("platform:/plugin/texteditor-core/" + location); InputStream inputStream = url.openConnection().getInputStream(); return Optional.of(new Image(Display.getCurrent(), inputStream)); } catch (IOException e) { return Optional.empty(); } }
From source file:com.teradata.benchto.driver.utils.PropertiesUtils.java
public static Optional<List<String>> splitProperty(String value) { if (isNullOrEmpty(value)) { return Optional.empty(); }/*from ww w.j a va 2s . co m*/ Iterable<String> values = Splitter.on(",").trimResults().split(value); return Optional.of(ImmutableList.copyOf(values)); }
From source file:org.openmhealth.shim.jawbone.mapper.JawboneBodyWeightDataPointMapper.java
@Override protected Optional<Measure.Builder<BodyWeight, ?>> newMeasureBuilder(JsonNode listEntryNode) { Optional<Double> optionalWeight = asOptionalDouble(listEntryNode, "weight"); if (!optionalWeight.isPresent()) { return Optional.empty(); }/*from w w w.ja v a 2 s.c o m*/ return Optional.of(new BodyWeight.Builder(new MassUnitValue(KILOGRAM, optionalWeight.get()))); }
From source file:org.trustedanalytics.cloud.cc.api.CcOrg.java
@JsonIgnore public UUID getGuid() { Optional<CcOrg> space = Optional.of(this); return space.map(CcOrg::getMetadata).map(CcMetadata::getGuid).orElse(null); }
From source file:org.openmhealth.shim.withings.mapper.WithingsBodyWeightDataPointMapper.java
@Override public Optional<Measure.Builder<BodyWeight, ?>> newMeasureBuilder(JsonNode measuresNode) { Optional<BigDecimal> value = getValueForMeasureType(measuresNode, BODY_WEIGHT); if (!value.isPresent()) { return empty(); }// w w w .j a v a2 s . co m return Optional.of(new BodyWeight.Builder(new MassUnitValue(KILOGRAM, value.get()))); }