replaced streams with for loop for serviceprovider lookup to resolves null type safety warning from Collectors.toMap
SonarQube Analysis / Build and Analyze (pull_request) Successful in 3m51s
SonarQube Analysis / Build and Analyze (pull_request) Successful in 3m51s
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.vaessl.app.connection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -18,8 +18,11 @@ public class ConnectionService {
|
||||
private final ConnectionRepository cRepository;
|
||||
|
||||
public ConnectionService(List<ConnectionProvider> providers, ConnectionRepository cRepository) {
|
||||
this.providerRegistry = providers.stream()
|
||||
.collect(Collectors.toMap(ConnectionProvider::getServiceType, p -> p));
|
||||
Map<ServiceType, ConnectionProvider> registry = new EnumMap<>(ServiceType.class);
|
||||
for (ConnectionProvider provider : providers) {
|
||||
registry.put(provider.getServiceType(), provider);
|
||||
}
|
||||
this.providerRegistry = registry;
|
||||
this.cRepository = cRepository;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user