1 /***
2 * Ambient - A music player for the Android platform
3 Copyright (C) 2007 Martin Vysny
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package sk.baka.ambient.playlist;
19
20 import java.io.Serializable;
21
22 import sk.baka.ambient.collection.TrackMetadataBean;
23
24 /***
25 * Describes a playlist item at particular index. All properties except the
26 * {@link #track} are mutable. An instance of playlist item is equal only to
27 * itself.
28 *
29 * @author Martin Vysny
30 */
31 public final class PlaylistItem implements Serializable {
32
33 private static final long serialVersionUID = 2078282720983760799L;
34
35 /***
36 * The track meta.
37 */
38 TrackMetadataBean track;
39
40 /***
41 * how many times this track was played.
42 */
43 int playCount;
44
45 /***
46 * the order in which the track is queued, or <code>0</code> if the track
47 * is not queued.
48 */
49 int queueOrder;
50
51 /***
52 * Creates new playlist item.
53 *
54 * @param track
55 * the track meta
56 * @param queueOrder
57 * the order in which the track is queued, or <code>0</code> if
58 * the track is not queued.
59 * @param playCount
60 * how many times this track was played.
61 */
62 PlaylistItem(final TrackMetadataBean track, final int queueOrder,
63 final int playCount) {
64 super();
65 this.track = track;
66 this.queueOrder = queueOrder;
67 this.playCount = playCount;
68 }
69
70 /***
71 * how many times this track was played.
72 *
73 * @return the playCount
74 */
75 public int getPlayCount() {
76 return playCount;
77 }
78
79 /***
80 * the order in which the track is queued, or <code>0</code> if the track
81 * is not queued.
82 *
83 * @return the queueOrder
84 */
85 public int getQueueOrder() {
86 return queueOrder;
87 }
88
89 /***
90 * The track meta.
91 *
92 * @return the track
93 */
94 public TrackMetadataBean getTrack() {
95 return track;
96 }
97
98 @Override
99 public String toString() {
100 final StringBuilder builder = new StringBuilder();
101 builder.append("Track: ");
102 builder.append(track);
103 builder.append("; played ");
104 builder.append(playCount);
105 builder.append(" times");
106 if (queueOrder != 0) {
107 builder.append("; queued ");
108 builder.append(queueOrder);
109 }
110 return builder.toString();
111 }
112
113 }