@Test public void testEmpty() { ContingenciesProvider provider = n -> Collections.emptyList(); Network network = Mockito.mock(Network.class); List<String> subList1 = new SubContingenciesProvider(provider, new Partition(1, 1)) .getContingencies(network) .stream().map(Contingency::getId).collect(Collectors.toList()); assertEquals(Collections.emptyList(), subList1); }
@Override public List<Contingency> getContingencies(Network network) { List<Contingency> fullList = delegate.getContingencies(network); int fullSize = fullList.size(); int start = partition.startIndex(fullSize); int end = partition.endIndex(fullSize); return new ArrayList<>(fullList.subList(start, end)); }
SubContingenciesProvider implements ContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { List<Contingency> fullList = delegate.getContingencies(network); int fullSize = fullList.size(); int start = partition.startIndex(fullSize); int end = partition.endIndex(fullSize); return new ArrayList<>(fullList.subList(start, end)); } }
SubContingenciesProvider implements ContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { List<Contingency> fullList = delegate.getContingencies(network); int fullSize = fullList.size(); int start = partition.startIndex(fullSize); int end = partition.endIndex(fullSize); return new ArrayList<>(fullList.subList(start, end)); } SubContingenciesProvider(ContingenciesProvider delegate, Partition partition); }
SubContingenciesProvider implements ContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { List<Contingency> fullList = delegate.getContingencies(network); int fullSize = fullList.size(); int start = partition.startIndex(fullSize); int end = partition.endIndex(fullSize); return new ArrayList<>(fullList.subList(start, end)); } SubContingenciesProvider(ContingenciesProvider delegate, Partition partition); @Override List<Contingency> getContingencies(Network network); }
SubContingenciesProvider implements ContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { List<Contingency> fullList = delegate.getContingencies(network); int fullSize = fullList.size(); int start = partition.startIndex(fullSize); int end = partition.endIndex(fullSize); return new ArrayList<>(fullList.subList(start, end)); } SubContingenciesProvider(ContingenciesProvider delegate, Partition partition); @Override List<Contingency> getContingencies(Network network);  }