List of usage examples for com.google.common.base Optional transform
public abstract <V> Optional<V> transform(Function<? super T, V> function);
From source file:com.eucalyptus.auth.euare.EuareRemoteRegionService.java
private <R extends IdentityMessage> R send( //TODO:STEVE: move send to a helper (also RemoteIdentityProvider#send) final Optional<RegionInfo> region, final IdentityMessage request) throws Exception { final Optional<Set<String>> endpoints = region.transform(RegionInfo.serviceEndpoints("identity")); final ServiceConfiguration config = new EphemeralConfiguration(ComponentIds.lookup(Identity.class), "identity", "identity", URI.create(Iterables.get(endpoints.get(), 0))); //TODO:STEVE: endpoint handling return AsyncRequests.sendSync(config, request); }
From source file:com.facebook.buck.java.JavaLibraryBuildRuleFactory.java
@Override protected void amendBuilder(DefaultJavaLibraryRule.Builder builder, BuildRuleFactoryParams params) throws NoSuchBuildTargetException { Optional<String> proguardConfig = params.getOptionalStringAttribute("proguard_config"); builder.setProguardConfig(//from ww w .j a v a2 s. co m proguardConfig.transform(params.getResolveFilePathRelativeToBuildFileDirectoryTransform())); for (String exportedDep : params.getOptionalListAttribute("exported_deps")) { BuildTarget buildTarget = params.resolveBuildTarget(exportedDep); builder.addExportedDep(buildTarget); } extractAnnotationProcessorParameters(builder.getAnnotationProcessingBuilder(), builder, params); Optional<String> sourceLevel = params.getOptionalStringAttribute("source"); if (sourceLevel.isPresent()) { builder.setSourceLevel(sourceLevel.get()); } Optional<String> targetLevel = params.getOptionalStringAttribute("target"); if (targetLevel.isPresent()) { builder.setTargetLevel(targetLevel.get()); } }
From source file:springfox.documentation.schema.property.ObjectMapperBeanPropertyNamingStrategy.java
@Override public String nameForSerialization(final BeanPropertyDefinition beanProperty) { SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); Optional<PropertyNamingStrategy> namingStrategy = Optional .fromNullable(serializationConfig.getPropertyNamingStrategy()); String newName = namingStrategy .transform(BeanPropertyDefinitions.overTheWireName(beanProperty, serializationConfig)) .or(beanProperty.getName()); LOG.debug("Name '{}' renamed to '{}'", beanProperty.getName(), newName); return newName; }
From source file:springfox.documentation.schema.property.ObjectMapperBeanPropertyNamingStrategy.java
@Override public String nameForDeserialization(final BeanPropertyDefinition beanProperty) { DeserializationConfig deserializationConfig = objectMapper.getDeserializationConfig(); Optional<PropertyNamingStrategy> namingStrategy = Optional .fromNullable(deserializationConfig.getPropertyNamingStrategy()); String newName = namingStrategy .transform(BeanPropertyDefinitions.overTheWireName(beanProperty, deserializationConfig)) .or(beanProperty.getName()); LOG.debug("Name '{}' renamed to '{}'", beanProperty.getName(), newName); return newName; }
From source file:com.qcadoo.mes.deviationCausesReporting.hooks.DeviationReportGeneratorViewHooks.java
private boolean isViewAlreadyInitialized(final ViewDefinitionState view) { Optional<CheckBoxComponent> maybeCheckBox = view .tryFindComponentByReference(DeviationReportGeneratorViewReferences.IS_VIEW_INITIALIZED); return maybeCheckBox.transform(new Function<CheckBoxComponent, Boolean>() { @Override/* w w w . j a v a 2s.c o m*/ public Boolean apply(final CheckBoxComponent component) { return component.isChecked(); } }).or(false); }
From source file:com.qcadoo.mes.productionPerShift.dates.OrderRealizationDaysResolver.java
private boolean shiftWorkTimeMatchPredicate(final Optional<Shift> maybeShift, final Optional<TimeRange> workTime, final Function<TimeRange, Boolean> workTimePredicate) { return maybeShift.transform(shift -> workTime.transform(workTimePredicate).or(false)).or(false); }
From source file:org.apache.james.imap.processor.GetAnnotationProcessor.java
private Optional<Integer> getMaxSizeValue(final List<MailboxAnnotation> mailboxAnnotations, Optional<Integer> maxsize) { if (maxsize.isPresent()) { return maxsize.transform(new Function<Integer, Optional<Integer>>() { @Override//from ww w . j av a2 s . co m public Optional<Integer> apply(Integer input) { return getMaxSizeOfOversizedItems(mailboxAnnotations, input); } }).get(); } return Optional.absent(); }
From source file:org.apache.aurora.scheduler.mesos.DriverFactoryImpl.java
@Override public SchedulerDriver create(Scheduler scheduler, Optional<Protos.Credential> credentials, Protos.FrameworkInfo frameworkInfo, String master) { FrameworkInfo convertedFrameworkInfo = convert(frameworkInfo); Optional<Credential> convertedCredentials = credentials.transform(ProtosConversion::convert); if (credentials.isPresent()) { return new MesosSchedulerDriver(scheduler, convertedFrameworkInfo, master, false, // Disable implicit acknowledgements. convertedCredentials.get()); } else {/*ww w. j a v a2s.c o m*/ return new MesosSchedulerDriver(scheduler, convertedFrameworkInfo, master, false); // Disable implicit acknowledgements. } }
From source file:org.apache.james.mailbox.store.mail.model.impl.MessageParser.java
private Optional<String> contentType(Optional<ContentTypeField> contentTypeField) { return contentTypeField.transform(new Function<ContentTypeField, Optional<String>>() { @Override//from w ww.j a v a 2s . co m public Optional<String> apply(ContentTypeField field) { return Optional.fromNullable(field.getMimeType()); } }).or(Optional.<String>absent()); }
From source file:org.apache.james.mailbox.store.mail.model.impl.MessageParser.java
private Optional<Cid> cid(Optional<ContentIdField> contentIdField) { return contentIdField.transform(new Function<ContentIdField, Optional<Cid>>() { @Override/*from w w w. j a v a 2 s. co m*/ public Optional<Cid> apply(ContentIdField field) { return Optional.fromNullable(field.getId()).transform(new Function<String, Cid>() { @Override public Cid apply(String cid) { return Cid.from(cid); } }); } }).or(Optional.<Cid>absent()); }