use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class OAuth2ClientPropertiesRegistrationAdapter method getBuilder.
private static Builder getBuilder(Builder builder, Provider provider) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(provider::getAuthorizationUri).to(builder::authorizationUri);
map.from(provider::getTokenUri).to(builder::tokenUri);
map.from(provider::getUserInfoUri).to(builder::userInfoUri);
map.from(provider::getUserInfoAuthenticationMethod).as(AuthenticationMethod::new).to(builder::userInfoAuthenticationMethod);
map.from(provider::getJwkSetUri).to(builder::jwkSetUri);
map.from(provider::getUserNameAttribute).to(builder::userNameAttributeName);
return builder;
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class KafkaAutoConfiguration method kafkaTemplate.
@Bean
@ConditionalOnMissingBean(KafkaTemplate.class)
public KafkaTemplate<?, ?> kafkaTemplate(ProducerFactory<Object, Object> kafkaProducerFactory, ProducerListener<Object, Object> kafkaProducerListener, ObjectProvider<RecordMessageConverter> messageConverter) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
KafkaTemplate<Object, Object> kafkaTemplate = new KafkaTemplate<>(kafkaProducerFactory);
messageConverter.ifUnique(kafkaTemplate::setMessageConverter);
map.from(kafkaProducerListener).to(kafkaTemplate::setProducerListener);
map.from(this.properties.getTemplate().getDefaultTopic()).to(kafkaTemplate::setDefaultTopic);
map.from(this.properties.getTemplate().getTransactionIdPrefix()).to(kafkaTemplate::setTransactionIdPrefix);
return kafkaTemplate;
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class RestDocsRestAssuredBuilderCustomizer method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
PropertyMapper map = PropertyMapper.get();
String host = this.properties.getUriHost();
map.from(this.properties::getUriScheme).when((scheme) -> StringUtils.hasText(scheme) && StringUtils.hasText(host)).to((scheme) -> this.delegate.baseUri(scheme + "://" + host));
map.from(this.properties::getUriPort).whenNonNull().to(this.delegate::port);
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class BasicBatchConfigurer method createJobExplorer.
protected JobExplorer createJobExplorer() throws Exception {
PropertyMapper map = PropertyMapper.get();
JobExplorerFactoryBean factory = new JobExplorerFactoryBean();
factory.setDataSource(this.dataSource);
map.from(this.properties.getJdbc()::getTablePrefix).whenHasText().to(factory::setTablePrefix);
factory.afterPropertiesSet();
return factory.getObject();
}
use of org.springframework.boot.context.properties.PropertyMapper in project spring-boot by spring-projects.
the class CassandraAutoConfiguration method mapRequestOptions.
private void mapRequestOptions(CassandraProperties properties, CassandraDriverOptions options) {
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
Request requestProperties = properties.getRequest();
map.from(requestProperties::getTimeout).asInt(Duration::toMillis).to(((timeout) -> options.add(DefaultDriverOption.REQUEST_TIMEOUT, timeout)));
map.from(requestProperties::getConsistency).to(((consistency) -> options.add(DefaultDriverOption.REQUEST_CONSISTENCY, consistency)));
map.from(requestProperties::getSerialConsistency).to((serialConsistency) -> options.add(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY, serialConsistency));
map.from(requestProperties::getPageSize).to((pageSize) -> options.add(DefaultDriverOption.REQUEST_PAGE_SIZE, pageSize));
Throttler throttlerProperties = requestProperties.getThrottler();
map.from(throttlerProperties::getType).as(ThrottlerType::type).to((type) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_CLASS, type));
map.from(throttlerProperties::getMaxQueueSize).to((maxQueueSize) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE, maxQueueSize));
map.from(throttlerProperties::getMaxConcurrentRequests).to((maxConcurrentRequests) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS, maxConcurrentRequests));
map.from(throttlerProperties::getMaxRequestsPerSecond).to((maxRequestsPerSecond) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND, maxRequestsPerSecond));
map.from(throttlerProperties::getDrainInterval).asInt(Duration::toMillis).to((drainInterval) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_DRAIN_INTERVAL, drainInterval));
}
Aggregations