use of io.micronaut.context.env.Environment in project micronaut-kafka by micronaut-projects.
the class KafkaDefaultConfiguration method resolveDefaultConfiguration.
private static Properties resolveDefaultConfiguration(Environment environment) {
Map<String, Object> values = environment.containsProperties(PREFIX) ? environment.getProperties(PREFIX) : Collections.emptyMap();
Properties properties = new Properties();
values.entrySet().stream().filter(entry -> {
String key = entry.getKey();
return Stream.of("embedded", "consumers", "producers", "streams").noneMatch(key::startsWith);
}).forEach(entry -> {
Object value = entry.getValue();
if (ConversionService.SHARED.canConvert(entry.getValue().getClass(), String.class)) {
Optional<?> converted = ConversionService.SHARED.convert(entry.getValue(), String.class);
if (converted.isPresent()) {
value = converted.get();
}
}
properties.setProperty(entry.getKey(), value.toString());
});
return properties;
}
Aggregations