List of usage examples for org.springframework.boot.context.properties PropertyMapper from
public <T> Source<T> from(T value)
From source file:org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration.java
@Bean @ConditionalOnMissingBean// w w w . j a v a 2 s . c om public RestClientBuilder restClientBuilder() { HttpHost[] hosts = this.properties.getUris().stream().map(HttpHost::create).toArray(HttpHost[]::new); RestClientBuilder builder = RestClient.builder(hosts); PropertyMapper map = PropertyMapper.get(); map.from(this.properties::getUsername).whenHasText().to((username) -> { CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); Credentials credentials = new UsernamePasswordCredentials(this.properties.getUsername(), this.properties.getPassword()); credentialsProvider.setCredentials(AuthScope.ANY, credentials); builder.setHttpClientConfigCallback( (httpClientBuilder) -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)); }); this.builderCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder)); return builder; }