public static List<MusicProtocol.MusicTrack> convertToAppleMusicPlaylistTracks(Collection<MusicPlaylistItem> musicPlaylistItems) {
        List<MusicProtocol.MusicTrack> convertedTracks = new ArrayList<>();
        for (MusicPlaylistItem item : musicPlaylistItems) {
            if (item == null) {
                throw new IllegalStateException("MusicPlaylistItem cannot be null");
            }

            if (StringUtils.isBlank(item.getPlaylistId())) {
                throw new IllegalStateException("MusicPlaylistIte::getPlaylistId cannot be blank");
            }

            MusicProtocol.MusicTrack.Builder trackBuilder = convertMusicRecordingToTrackBuilder(item.getTrack());

            trackBuilder.setPlaylistId(item.getPlaylistId())
                    .setPlaylistPosition(item.getOrder());

            convertedTracks.add(trackBuilder.build());
        }

        return convertedTracks;
    }
Helper class for converting incoming DTP format playlists and playlist-tracks to Apple Music format for transport to
Apple Music Data Transfer services.
extensions/data-transfer/portability-data-transfer-apple/src/main/java/org/datatransferproject/datatransfer/apple/music/data/converters/AppleMusicPlaylistConverter.java