Beispiel #1
0
  private SortedSet<Artist> createArtists(
      List<MusicFolder> folders, String[] ignoredArticles, String[] shortcuts) throws IOException {
    SortedMap<String, Artist> artistMap = new TreeMap<String, Artist>();
    Set<String> shortcutSet = new HashSet<String>(Arrays.asList(shortcuts));

    for (MusicFolder folder : folders) {

      MusicFile parent = musicFileService.getMusicFile(folder.getPath());
      List<MusicFile> children = musicFileService.getChildDirectories(parent);
      for (MusicFile child : children) {
        if (shortcutSet.contains(child.getName())) {
          continue;
        }

        String sortableName = createSortableName(child.getName(), ignoredArticles);
        Artist artist = artistMap.get(sortableName);
        if (artist == null) {
          artist = new Artist(child.getName(), sortableName);
          artistMap.put(sortableName, artist);
        }
        artist.addMusicFile(child);
      }
    }

    return new TreeSet<Artist>(artistMap.values());
  }