001package net.filebot.web;
002
003import static java.util.stream.Collectors.*;
004
005import java.io.Serializable;
006import java.util.Objects;
007import java.util.stream.Stream;
008
009public class AudioTrack implements Serializable {
010
011        protected String database;
012
013        protected String artist;
014        protected String title;
015        protected String album;
016
017        protected String albumArtist;
018        protected String trackTitle;
019        protected String genre;
020        protected SimpleDate albumReleaseDate;
021        protected Integer mediumIndex;
022        protected Integer mediumCount;
023        protected Integer trackIndex;
024        protected Integer trackCount;
025
026        protected String mbid; // MusicBrainz Identifier
027
028        public AudioTrack() {
029                // used by deserializer
030        }
031
032        public AudioTrack(AudioTrack other) {
033                this.artist = other.artist;
034                this.title = other.title;
035                this.album = other.album;
036                this.albumArtist = other.albumArtist;
037                this.trackTitle = other.trackTitle;
038                this.genre = other.genre;
039                this.albumReleaseDate = other.albumReleaseDate;
040                this.mediumIndex = other.mediumIndex;
041                this.mediumCount = other.mediumCount;
042                this.trackIndex = other.trackIndex;
043                this.trackCount = other.trackCount;
044                this.mbid = other.mbid;
045                this.database = other.database;
046        }
047
048        public AudioTrack(String artist, String title, String album, String database) {
049                this.artist = artist;
050                this.title = title;
051                this.album = album;
052                this.database = database;
053        }
054
055        public AudioTrack(String artist, String title, String album, String albumArtist, String trackTitle, String genre, SimpleDate albumReleaseDate, Integer mediumIndex, Integer mediumCount, Integer trackIndex, Integer trackCount, String mbid, String database) {
056                this.artist = artist;
057                this.title = title;
058                this.album = album;
059                this.albumArtist = albumArtist;
060                this.trackTitle = trackTitle;
061                this.genre = genre;
062                this.albumReleaseDate = albumReleaseDate;
063                this.mediumIndex = mediumIndex;
064                this.mediumCount = mediumCount;
065                this.trackIndex = trackIndex;
066                this.trackCount = trackCount;
067                this.mbid = mbid;
068                this.database = database;
069        }
070
071        public String getArtist() {
072                return artist;
073        }
074
075        public String getTitle() {
076                return title;
077        }
078
079        public String getAlbum() {
080                return album;
081        }
082
083        public String getAlbumArtist() {
084                return albumArtist;
085        }
086
087        public String getTrackTitle() {
088                return trackTitle;
089        }
090
091        public String getGenre() {
092                return genre;
093        }
094
095        public SimpleDate getAlbumReleaseDate() {
096                return albumReleaseDate;
097        }
098
099        public Integer getMedium() {
100                return mediumIndex;
101        }
102
103        public Integer getMediumCount() {
104                return mediumCount;
105        }
106
107        public Integer getTrack() {
108                return trackIndex;
109        }
110
111        public Integer getTrackCount() {
112                return trackCount;
113        }
114
115        public String getMBID() {
116                return mbid;
117        }
118
119        public String getDatabase() {
120                return database;
121        }
122
123        @Override
124        public AudioTrack clone() {
125                return new AudioTrack(this);
126        }
127
128        @Override
129        public String toString() {
130                return Stream.of(album, artist, title).filter(Objects::nonNull).map(Objects::toString).collect(joining(" - "));
131        }
132
133        @Override
134        public int hashCode() {
135                return Objects.hash(mbid, album, artist, title);
136        }
137
138        @Override
139        public boolean equals(Object other) {
140                if (other instanceof AudioTrack) {
141                        AudioTrack a = (AudioTrack) other;
142                        return Objects.equals(mbid, a.mbid) && Objects.equals(album, a.album) && Objects.equals(artist, a.artist) && Objects.equals(title, a.title);
143                }
144
145                return super.equals(other);
146        }
147
148}