Sho SHIMIZU
Committed by Gerrit Code Review

More idiomatic code in Stream API

Change-Id: Ifa5a311cfc1ce43f5eab80be9ddce5fa36e47d92
......@@ -40,6 +40,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
class MockResourceService implements ResourceService {
......@@ -49,7 +50,7 @@ class MockResourceService implements ResourceService {
@Override
public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
assignment.putAll(
resources.stream().collect(Collectors.toMap(x -> x, x -> consumer))
resources.stream().collect(Collectors.toMap(Function.identity(), x -> consumer))
);
return resources.stream()
......
......@@ -50,6 +50,7 @@ import org.slf4j.Logger;
import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -209,7 +210,7 @@ public class MeterManager extends AbstractListenerProviderRegistry<MeterEvent, M
//FIXME: FOLLOWING CODE CANNOT BE TESTED UNTIL SOMETHING THAT
//FIXME: IMPLEMENTS METERS EXISTS
Map<Pair<DeviceId, MeterId>, Meter> storedMeterMap = store.getAllMeters().stream()
.collect(Collectors.toMap(m -> Pair.of(m.deviceId(), m.id()), m -> m));
.collect(Collectors.toMap(m -> Pair.of(m.deviceId(), m.id()), Function.identity()));
meterEntries.stream()
.filter(m -> storedMeterMap.remove(Pair.of(m.deviceId(), m.id())) != null)
......