Class Playlist


  • public class Playlist
    extends java.lang.Object

    Package - The Playlist, a component of the User module, allows passengers to create a list of media content, such as movies, music or audiobooks, on their personal electronic devices (PED).



    The same Playlist can be used over multiple flights, if synchronized, and passengers can add and remove media content at any time.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(PlaylistItem playlistItem)
      Adds a single item to the end of the media queue.
      boolean add​(PlaylistItem playlistItem, int position)
      Adds a single item to the specific position in the FavouriteList.
      int add​(java.util.List<PlaylistItem> playlistItems)
      Adds all new media items to the end of the media queue, then returns the number of items on the List.
      int add​(java.util.List<PlaylistItem> playlistItems, int position)
      Inserts the provided media items into the FavouriteList at the specified position.
      void clear()
      Clears all media content from the Playlist.
      java.util.List<PlaylistItem> getItems()
      Gets a list of all media content, such as movies, music and audio books, in the Playlist.
      java.util.List<PlaylistItem> getItemsByContentType​(java.lang.String contentType)
      Returns a list of media items by ContentType.
      java.lang.String getPlaylistName()
      Returns the name of the playlist
      boolean remove​(PlaylistItem playlistItem)
      Removes a media content from the Playlist.
      boolean remove​(java.lang.String playlistItemId)
      Removes the specified media content from the Playlist.
      int remove​(java.util.List<java.lang.String> playlistItemIds)  
      java.lang.String toString()
      For internal use
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getPlaylistName

        public java.lang.String getPlaylistName()
        Returns the name of the playlist
        Returns:
        Name of the playlist
      • add

        public int add​(java.util.List<PlaylistItem> playlistItems)
                throws java.lang.NullPointerException,
                       java.lang.IllegalArgumentException
        Adds all new media items to the end of the media queue, then returns the number of items on the List.
        Parameters:
        playlistItems - A list of items to be added to the Playlist

        Returns:
        The number of items added
        Throws:
        java.lang.NullPointerException
        java.lang.IllegalArgumentException
      • add

        public int add​(java.util.List<PlaylistItem> playlistItems,
                       int position)
                throws java.lang.IndexOutOfBoundsException,
                       java.lang.NullPointerException,
                       java.lang.IllegalArgumentException
        Inserts the provided media items into the FavouriteList at the specified position. and returns the number of items added.

        If the provided position is invalid (less than 0 or greater than the current size of the FavouriteList), this method throws IndexOutOfBoundsException and no items are added.

        Parameters:
        playlistItems - A list of items to be inserted into the Playlist
        position - The index at which the items should be inserted
        Returns:
        The number of items added
        Throws:
        java.lang.IndexOutOfBoundsException
        java.lang.NullPointerException
        java.lang.IllegalArgumentException
      • add

        public boolean add​(PlaylistItem playlistItem)
                    throws java.lang.NullPointerException
        Adds a single item to the end of the media queue. This call verifies the media content is not currently in the Playlist. The list cannot contain identical media content.
        Parameters:
        playlistItem - to be added
        Returns:
        True, if added.
        Throws:
        java.lang.NullPointerException - False, if the content is identical to content currently in the Playlist.
      • add

        public boolean add​(PlaylistItem playlistItem,
                           int position)
                    throws java.lang.IndexOutOfBoundsException,
                           java.lang.NullPointerException
        Adds a single item to the specific position in the FavouriteList. This call verifies the media content is not currently in the Playlist. The list cannot contain identical media content.
        Parameters:
        playlistItem - to be added
        position - The index at which the items should be inserted
        Returns:
        True, if added.
        Throws:
        java.lang.IndexOutOfBoundsException
        java.lang.NullPointerException
      • remove

        public boolean remove​(PlaylistItem playlistItem)
        Removes a media content from the Playlist.
        Parameters:
        playlistItem - The Playlist item removed. It's removed as an object/
        Returns:
        True, if collection was modified
        False, if not modified.
      • remove

        public boolean remove​(java.lang.String playlistItemId)
        Removes the specified media content from the Playlist.
        Parameters:
        playlistItemId - The @Playlist. content to be removed
        Returns:
        True, if collection was modified
        False, if not modified.
      • remove

        public int remove​(java.util.List<java.lang.String> playlistItemIds)
      • clear

        public void clear()
        Clears all media content from the Playlist.
      • getItems

        public java.util.List<PlaylistItem> getItems()
        Gets a list of all media content, such as movies, music and audio books, in the Playlist.
        Returns:
      • getItemsByContentType

        public java.util.List<PlaylistItem> getItemsByContentType​(java.lang.String contentType)
        Returns a list of media items by ContentType.

        If there are no matching items, it return an empty list.
        Parameters:
        contentType - The media content type ContentType
        Returns:
        List of PlaylistItem
      • toString

        public java.lang.String toString()
        For internal use
        Overrides:
        toString in class java.lang.Object