Marc De Leenheer
Committed by Gerrit Code Review

Harmonize resource collectors.

Change-Id: I51fdf9cdf57d3146bd9401ff67e13063830519e4
......@@ -45,9 +45,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
......@@ -206,10 +204,9 @@ final class ResourceDeviceListener implements DeviceListener {
}
LambdaQuery query = handler.behaviour(LambdaQuery.class);
if (query != null) {
Supplier<SortedSet<OchSignal>> supplier = () -> new TreeSet<>(new DefaultOchSignalComparator());
return query.queryLambdas(port).stream()
.flatMap(x -> OchSignal.toFlexGrid(x).stream())
.collect(Collectors.toCollection(supplier));
.collect(Collectors.toCollection(DefaultOchSignalComparator::newOchSignalTreeSet));
} else {
return Collections.emptySortedSet();
}
......
......@@ -49,9 +49,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
......@@ -209,12 +207,11 @@ public class CalientFiberSwitchHandshaker
ChannelSpacing.CHL_12P5GHZ.frequency().asHz();
long stopSpacingMultiplier = Spectrum.O_BAND_MAX.subtract(Spectrum.CENTER_FREQUENCY).asHz() /
ChannelSpacing.CHL_12P5GHZ.frequency().asHz();
Supplier<SortedSet<OchSignal>> supplier = () -> new TreeSet<>(new DefaultOchSignalComparator());
// Only consider odd values for the multiplier (for easy mapping to fixed grid)
return IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier)
.filter(i -> i % 2 == 1)
.mapToObj(i -> new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1))
.collect(Collectors.toCollection(supplier));
.collect(Collectors.toCollection(DefaultOchSignalComparator::newOchSignalTreeSet));
}
}
......
......@@ -57,9 +57,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
......@@ -373,9 +371,8 @@ public class OfOpticalSwitchImplLinc13
}
// OMS ports expose 80 fixed grid lambdas of 50GHz width, centered around the ITU-T center frequency 193.1 THz.
Supplier<SortedSet<OchSignal>> supplier = () -> new TreeSet<>(new DefaultOchSignalComparator());
return IntStream.range(0, LAMBDA_COUNT)
.mapToObj(x -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, x - (LAMBDA_COUNT / 2), 4))
.collect(Collectors.toCollection(supplier));
.collect(Collectors.toCollection(DefaultOchSignalComparator::newOchSignalTreeSet));
}
}
......