class RepairRunService {

  static List<Segment> filterSegmentsByNodes(
      List<Segment> segments,
      RepairUnit repairUnit,
      Map<String, List<RingRange>> endpointToRange) {

    if (repairUnit.getNodes().isEmpty()) {
      return segments;
    } else {
      return segments
          .stream()
          .filter(
              segment -> {
                RingRange firstRange = segment.getBaseRange();
                for (Entry<String, List<RingRange>> entry : endpointToRange.entrySet()) {
                  if (repairUnit.getNodes().contains(entry.getKey())) {
                    for (RingRange range : entry.getValue()) {
                      if (range.encloses(firstRange)) {
                        return true;
                      }
                    }
                  }
                }
                return false;
              })
          .collect(Collectors.toList());
    }
  }

  private  RepairRunService(AppContext context);

}