2014-04-19 02:30:29 -04:00
|
|
|
package net.filebot.web;
|
2007-12-23 14:28:04 -05:00
|
|
|
|
2009-01-04 13:28:28 -05:00
|
|
|
import java.io.Serializable;
|
2015-01-18 03:57:37 -05:00
|
|
|
import java.util.ArrayList;
|
2009-07-23 10:25:43 -04:00
|
|
|
import java.util.Arrays;
|
2015-01-18 03:57:37 -05:00
|
|
|
import java.util.LinkedHashSet;
|
2014-01-04 14:31:38 -05:00
|
|
|
import java.util.List;
|
2015-01-18 03:57:37 -05:00
|
|
|
import java.util.Set;
|
2009-01-04 13:28:28 -05:00
|
|
|
|
|
|
|
public class Episode implements Serializable {
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2014-07-24 07:31:03 -04:00
|
|
|
protected String seriesName;
|
|
|
|
protected Integer season;
|
|
|
|
protected Integer episode;
|
|
|
|
protected String title;
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-11-09 03:04:12 -05:00
|
|
|
// absolute episode number
|
2014-07-24 07:31:03 -04:00
|
|
|
protected Integer absolute;
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-10-23 08:47:43 -04:00
|
|
|
// special number
|
2014-07-24 07:31:03 -04:00
|
|
|
protected Integer special;
|
|
|
|
|
2010-10-23 08:47:43 -04:00
|
|
|
// episode airdate
|
2014-07-24 07:31:03 -04:00
|
|
|
protected SimpleDate airdate;
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2014-12-10 13:53:58 -05:00
|
|
|
// extended series metadata
|
|
|
|
protected SeriesInfo seriesInfo;
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2009-10-28 11:09:47 -04:00
|
|
|
protected Episode() {
|
2014-12-10 13:53:58 -05:00
|
|
|
|
2009-10-28 11:09:47 -04:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2012-02-16 02:19:12 -05:00
|
|
|
public Episode(Episode obj) {
|
2014-12-10 13:53:58 -05:00
|
|
|
this(obj.seriesName, obj.season, obj.episode, obj.title, obj.absolute, obj.special, obj.airdate, obj.seriesInfo);
|
2012-02-16 02:19:12 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2014-12-10 13:53:58 -05:00
|
|
|
public Episode(String seriesName, Integer season, Integer episode, String title) {
|
|
|
|
this(seriesName, season, episode, title, null, null, null, null);
|
2010-02-03 16:36:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2014-12-10 13:53:58 -05:00
|
|
|
public Episode(String seriesName, Integer season, Integer episode, String title, Integer absolute, Integer special, SimpleDate airdate, SeriesInfo seriesInfo) {
|
2009-01-24 19:08:57 -05:00
|
|
|
this.seriesName = seriesName;
|
2009-05-03 11:21:04 -04:00
|
|
|
this.season = season;
|
|
|
|
this.episode = episode;
|
2007-12-23 14:28:04 -05:00
|
|
|
this.title = title;
|
2010-11-09 03:04:12 -05:00
|
|
|
this.absolute = absolute;
|
2010-02-03 16:36:04 -05:00
|
|
|
this.special = special;
|
2014-03-20 13:36:56 -04:00
|
|
|
this.airdate = (airdate == null ? null : airdate.clone());
|
2014-12-10 13:53:58 -05:00
|
|
|
this.seriesInfo = (seriesInfo == null ? null : seriesInfo.clone());
|
2010-10-23 08:47:43 -04:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-10-23 08:47:43 -04:00
|
|
|
public String getSeriesName() {
|
|
|
|
return seriesName;
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-10-24 08:10:30 -04:00
|
|
|
public Integer getEpisode() {
|
2009-05-03 11:21:04 -04:00
|
|
|
return episode;
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-10-24 08:10:30 -04:00
|
|
|
public Integer getSeason() {
|
2009-07-23 10:25:43 -04:00
|
|
|
return season;
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-10-23 08:47:43 -04:00
|
|
|
public String getTitle() {
|
|
|
|
return title;
|
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-11-09 03:04:12 -05:00
|
|
|
public Integer getAbsolute() {
|
|
|
|
return absolute;
|
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2010-10-24 08:10:30 -04:00
|
|
|
public Integer getSpecial() {
|
2010-02-03 16:36:04 -05:00
|
|
|
return special;
|
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2014-04-19 01:39:52 -04:00
|
|
|
public SimpleDate getAirdate() {
|
2010-10-23 08:47:43 -04:00
|
|
|
return airdate;
|
2009-05-03 11:21:04 -04:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2014-12-10 13:53:58 -05:00
|
|
|
public SeriesInfo getSeriesInfo() {
|
|
|
|
return seriesInfo;
|
2013-07-13 06:01:33 -04:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
|
|
|
public List<Integer> getNumbers() {
|
2016-02-26 11:35:59 -05:00
|
|
|
return Arrays.asList(season, episode, special, absolute);
|
2014-01-04 14:31:38 -05:00
|
|
|
}
|
|
|
|
|
2015-01-18 03:57:37 -05:00
|
|
|
public List<String> getSeriesNames() {
|
|
|
|
Set<String> names = new LinkedHashSet<String>();
|
|
|
|
if (seriesName != null) {
|
|
|
|
names.add(seriesName);
|
|
|
|
}
|
|
|
|
if (seriesInfo != null) {
|
|
|
|
if (seriesInfo.name != null) {
|
|
|
|
names.add(seriesInfo.name);
|
|
|
|
}
|
|
|
|
if (seriesInfo.aliasNames != null) {
|
|
|
|
for (String it : seriesInfo.aliasNames) {
|
|
|
|
names.add(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new ArrayList<String>(names);
|
|
|
|
}
|
|
|
|
|
2009-07-23 10:25:43 -04:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (obj instanceof Episode) {
|
|
|
|
Episode other = (Episode) obj;
|
2016-02-26 11:35:59 -05:00
|
|
|
return equals(season, other.season) && equals(episode, other.episode) && equals(absolute, other.absolute) && equals(special, other.special) && equals(seriesName, other.seriesName) && equals(title, other.title);
|
2009-05-03 11:21:04 -04:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2009-07-23 10:25:43 -04:00
|
|
|
return false;
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2009-07-23 10:25:43 -04:00
|
|
|
private boolean equals(Object o1, Object o2) {
|
|
|
|
if (o1 == null || o2 == null)
|
|
|
|
return o1 == o2;
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2009-07-23 10:25:43 -04:00
|
|
|
return o1.equals(o2);
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2009-07-23 10:25:43 -04:00
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
2016-02-26 11:35:59 -05:00
|
|
|
return Arrays.hashCode(new Object[] { season, episode, absolute, special, seriesName, title });
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2012-10-15 14:04:38 -04:00
|
|
|
@Override
|
|
|
|
public Episode clone() {
|
|
|
|
return new Episode(this);
|
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2009-03-08 15:55:05 -04:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2011-09-09 10:50:01 -04:00
|
|
|
return EpisodeFormat.SeasonEpisode.format(this);
|
2009-01-04 13:28:28 -05:00
|
|
|
}
|
2014-01-04 14:31:38 -05:00
|
|
|
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|