Exemplo n.º 1
0
    /**
     * Return true if @recording's destination already exists or is a duplicate of another queued
     * recording
     */
    private boolean destinationExistsOrIsDuplicate(Recording recording) {
      if (Files.exists(recording.getDestination())) {
        return true;
      }

      for (Recording earlierRecording : recordings) {
        if (earlierRecording == recording) {
          break;
        } else {
          if (recording.getDestination().equals(earlierRecording.getDestination())) {
            return true;
          }
        }
      }

      return false;
    }
Exemplo n.º 2
0
  public static List<Recording> getRecordingsWithDuplicateDestination(List<Recording> recordings) {
    Set<Path> seen = new HashSet<>();
    Set<Path> duplicatePaths = new HashSet<>();
    for (Recording recording : recordings) {
      Path destination = recording.getDestination();
      if (seen.contains(destination)) {
        duplicatePaths.add(destination);
      } else {
        seen.add(destination);
      }
    }

    return recordings
        .stream()
        .filter(recording -> duplicatePaths.contains(recording.getDestination()))
        .collect(Collectors.toList());
  }