mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
* make sure the Episode/Movie object graphs don't share any objects so json-io won't write json with @ref attributes
This commit is contained in:
parent
d2b2b453b5
commit
1ae64235f1
@ -44,4 +44,10 @@ public class AnidbSearchResult extends SearchResult {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnidbSearchResult clone() {
|
||||
return new AnidbSearchResult(aid, name, aliasNames);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import static java.util.Calendar.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -12,46 +10,38 @@ import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class Date implements Serializable {
|
||||
|
||||
private int year;
|
||||
private int month;
|
||||
private int day;
|
||||
|
||||
|
||||
protected Date() {
|
||||
// used by serializer
|
||||
}
|
||||
|
||||
|
||||
public Date(int year, int month, int day) {
|
||||
this.year = year;
|
||||
this.month = month;
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
|
||||
public int getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
|
||||
public int getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
|
||||
public long getTimeStamp() {
|
||||
return new GregorianCalendar(year, month - 1, day).getTimeInMillis(); // Month value is 0-based, e.g. 0 for January
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Date) {
|
||||
@ -62,29 +52,29 @@ public class Date implements Serializable {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(new Object[] { year, month, day });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date clone() {
|
||||
return new Date(year, month, day);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%04d-%02d-%02d", year, month, day);
|
||||
}
|
||||
|
||||
|
||||
public String format(String pattern) {
|
||||
return format(pattern, Locale.ROOT);
|
||||
}
|
||||
|
||||
|
||||
public String format(String pattern, Locale locale) {
|
||||
return new SimpleDateFormat(pattern, locale).format(new GregorianCalendar(year, month - 1, day).getTime()); // Calendar months start at 0
|
||||
}
|
||||
|
||||
|
||||
public static Date parse(String string, String pattern) {
|
||||
if (string == null || string.isEmpty())
|
||||
return null;
|
||||
|
@ -39,14 +39,14 @@ public class Episode implements Serializable {
|
||||
|
||||
public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title, Integer absolute, Integer special, Date airdate, SearchResult series) {
|
||||
this.seriesName = seriesName;
|
||||
this.seriesStartDate = seriesStartDate;
|
||||
this.seriesStartDate = (seriesStartDate == null ? null : seriesStartDate.clone());
|
||||
this.season = season;
|
||||
this.episode = episode;
|
||||
this.title = title;
|
||||
this.absolute = absolute;
|
||||
this.special = special;
|
||||
this.airdate = airdate;
|
||||
this.series = series;
|
||||
this.airdate = (airdate == null ? null : airdate.clone());
|
||||
this.series = (series == null ? null : series.clone());
|
||||
}
|
||||
|
||||
public String getSeriesName() {
|
||||
|
@ -1,34 +1,27 @@
|
||||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class HyperLink extends SearchResult {
|
||||
|
||||
protected URL url;
|
||||
|
||||
|
||||
protected HyperLink() {
|
||||
// used by serializer
|
||||
}
|
||||
|
||||
|
||||
public HyperLink(String name, URL url) {
|
||||
super(name);
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
public URL getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
public URI getURI() {
|
||||
try {
|
||||
return url.toURI();
|
||||
@ -37,7 +30,6 @@ public class HyperLink extends SearchResult {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof HyperLink) {
|
||||
@ -48,10 +40,14 @@ public class HyperLink extends SearchResult {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(new Object[] { name, url.toString() });
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyperLink clone() {
|
||||
return new HyperLink(name, url);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,27 +1,24 @@
|
||||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MultiEpisode extends Episode {
|
||||
|
||||
private Episode[] episodes;
|
||||
|
||||
|
||||
public MultiEpisode(Episode... episodes) {
|
||||
super(episodes[0]);
|
||||
this.episodes = episodes;
|
||||
}
|
||||
|
||||
|
||||
public List<Episode> getEpisodes() {
|
||||
return Arrays.asList(episodes);
|
||||
return unmodifiableList(asList(episodes));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MultiEpisode) {
|
||||
@ -31,19 +28,16 @@ public class MultiEpisode extends Episode {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(episodes);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MultiEpisode clone() {
|
||||
return new MultiEpisode(this.episodes);
|
||||
return new MultiEpisode(episodes.clone());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return EpisodeFormat.SeasonEpisode.formatMultiEpisode(getEpisodes());
|
||||
|
@ -46,6 +46,9 @@ public abstract class SearchResult implements Serializable {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract SearchResult clone();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
|
@ -47,4 +47,10 @@ public class SerienjunkiesSearchResult extends SearchResult {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerienjunkiesSearchResult clone() {
|
||||
return new SerienjunkiesSearchResult(sid, link, name, aliasNames, startDate == null ? null : startDate.clone());
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +1,37 @@
|
||||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
public class TVRageSearchResult extends SearchResult {
|
||||
|
||||
protected int showId;
|
||||
protected String link;
|
||||
|
||||
|
||||
protected TVRageSearchResult() {
|
||||
// used by serializer
|
||||
}
|
||||
|
||||
|
||||
public TVRageSearchResult(String name, int showId, String link) {
|
||||
super(name);
|
||||
this.showId = showId;
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return showId;
|
||||
}
|
||||
|
||||
|
||||
public int getSeriesId() {
|
||||
return showId;
|
||||
}
|
||||
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return showId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof TVRageSearchResult) {
|
||||
@ -50,4 +41,10 @@ public class TVRageSearchResult extends SearchResult {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TVRageSearchResult clone() {
|
||||
return new TVRageSearchResult(name, showId, link);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
public class TheTVDBSearchResult extends SearchResult {
|
||||
|
||||
protected int seriesId;
|
||||
@ -40,4 +39,10 @@ public class TheTVDBSearchResult extends SearchResult {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TheTVDBSearchResult clone() {
|
||||
return new TheTVDBSearchResult(name, seriesId);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user