sk.baka.ambient.playlist
Enum Random

java.lang.Object
  extended by java.lang.Enum<Random>
      extended by sk.baka.ambient.playlist.Random
All Implemented Interfaces:
Serializable, Comparable<Random>

public enum Random
extends Enum<Random>

Random play.

Author:
Martin Vysny

Enum Constant Summary
ALBUM
          A random album is selected which is then played regularly (in album order).
ALBUM_PLAYLIST
          A random album is selected which is then played in the playlist order (order in which tracks appear in the playlist).
ALBUM_TRACK
          A random album is selected and random tracks are played from it.
NONE
          No random play, tracks will be played as ordered by the playlist.
TRACK
           
 
Method Summary
 boolean groupsByAlbum()
          Checks if this random mode groups tracks by albums.
static List<PlaylistItem> randomize(Random random, List<? extends PlaylistItem> playlist, PlaylistItem first)
          Randomizes given playlist as specified by the Random constant.
static Random valueOf(String name)
          Returns the enum constant of this type with the specified name.
static Random[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NONE

public static final Random NONE
No random play, tracks will be played as ordered by the playlist.


TRACK

public static final Random TRACK

ALBUM

public static final Random ALBUM
A random album is selected which is then played regularly (in album order).


ALBUM_PLAYLIST

public static final Random ALBUM_PLAYLIST
A random album is selected which is then played in the playlist order (order in which tracks appear in the playlist).


ALBUM_TRACK

public static final Random ALBUM_TRACK
A random album is selected and random tracks are played from it.

Method Detail

values

public static Random[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Random c : Random.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Random valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

randomize

public static List<PlaylistItem> randomize(Random random,
                                           List<? extends PlaylistItem> playlist,
                                           PlaylistItem first)
Randomizes given playlist as specified by the Random constant.

Parameters:
random - the random constant
playlist - the playlist to randomize, will not be changed.
first - place this track first if possible. May be null if it doesn't matter which track is the first one.
Returns:
a new, shuffled list.

groupsByAlbum

public final boolean groupsByAlbum()
Checks if this random mode groups tracks by albums.

Returns:
true if tracks are grouped by albums (ALBUM, ALBUM_PLAYLIST and ALBUM_TRACK) , false otherwise.


Copyright © 2007-2008. All Rights Reserved.