Refactor model packages
This commit is contained in:
@@ -42,7 +42,7 @@ import com.omertron.themoviedbapi.methods.TmdbPeople;
|
||||
import com.omertron.themoviedbapi.methods.TmdbReviews;
|
||||
import com.omertron.themoviedbapi.methods.TmdbSearch;
|
||||
import com.omertron.themoviedbapi.methods.TmdbTV;
|
||||
import com.omertron.themoviedbapi.model.Genre;
|
||||
import com.omertron.themoviedbapi.model2.Genre;
|
||||
import com.omertron.themoviedbapi.model.keyword.KeywordMovie;
|
||||
import com.omertron.themoviedbapi.model2.Certification;
|
||||
import com.omertron.themoviedbapi.model2.FindResults;
|
||||
|
||||
@@ -46,7 +46,6 @@ public class TmdbFind extends AbstractMethod {
|
||||
*/
|
||||
public TmdbFind(String apiKey, HttpTools httpTools) {
|
||||
super(apiKey, httpTools);
|
||||
// MAPPER.addMixIn(MediaBasic.class, MediaTypeMixIn.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.omertron.themoviedbapi.methods;
|
||||
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.model.Genre;
|
||||
import com.omertron.themoviedbapi.model2.Genre;
|
||||
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
|
||||
@@ -21,11 +21,11 @@ package com.omertron.themoviedbapi.methods;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.model.ListItemStatus;
|
||||
import com.omertron.themoviedbapi.model2.movie.MovieDb;
|
||||
import com.omertron.themoviedbapi.model.MovieDbListStatus;
|
||||
import com.omertron.themoviedbapi.model2.StatusCode;
|
||||
import com.omertron.themoviedbapi.model2.list.ListItem;
|
||||
import com.omertron.themoviedbapi.model2.list.ListItemStatus;
|
||||
import com.omertron.themoviedbapi.model2.movie.MovieDb;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
import com.omertron.themoviedbapi.tools.HttpTools;
|
||||
import com.omertron.themoviedbapi.tools.MethodBase;
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Stuart
|
||||
*/
|
||||
public class MovieList extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
@JsonProperty("favorite_count")
|
||||
private int favoriteCount;
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("item_count")
|
||||
private int itemCount;
|
||||
@JsonProperty("iso_639_1")
|
||||
private String language;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("poster_path")
|
||||
private String posterPath;
|
||||
@JsonProperty("list_type")
|
||||
private String listType;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getFavoriteCount() {
|
||||
return favoriteCount;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getPosterPath() {
|
||||
return posterPath;
|
||||
}
|
||||
|
||||
public String getListType() {
|
||||
return listType;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setFavoriteCount(int favoriteCount) {
|
||||
this.favoriteCount = favoriteCount;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setItemCount(int itemCount) {
|
||||
this.itemCount = itemCount;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setPosterPath(String posterPath) {
|
||||
this.posterPath = posterPath;
|
||||
}
|
||||
|
||||
public void setListType(String listType) {
|
||||
this.listType = listType;
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class TmdbConfiguration extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@JsonProperty("base_url")
|
||||
private String baseUrl;
|
||||
@JsonProperty("secure_base_url")
|
||||
private String secureBaseUrl;
|
||||
@JsonProperty("poster_sizes")
|
||||
private List<String> posterSizes;
|
||||
@JsonProperty("backdrop_sizes")
|
||||
private List<String> backdropSizes;
|
||||
@JsonProperty("profile_sizes")
|
||||
private List<String> profileSizes;
|
||||
@JsonProperty("logo_sizes")
|
||||
private List<String> logoSizes;
|
||||
@JsonProperty("still_sizes")
|
||||
private List<String> stillSizes;
|
||||
|
||||
public List<String> getBackdropSizes() {
|
||||
return backdropSizes;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public List<String> getPosterSizes() {
|
||||
return posterSizes;
|
||||
}
|
||||
|
||||
public List<String> getProfileSizes() {
|
||||
return profileSizes;
|
||||
}
|
||||
|
||||
public List<String> getLogoSizes() {
|
||||
return logoSizes;
|
||||
}
|
||||
|
||||
public String getSecureBaseUrl() {
|
||||
return secureBaseUrl;
|
||||
}
|
||||
|
||||
public List<String> getStillSizes() {
|
||||
return stillSizes;
|
||||
}
|
||||
|
||||
public void setBackdropSizes(List<String> backdropSizes) {
|
||||
this.backdropSizes = backdropSizes;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public void setPosterSizes(List<String> posterSizes) {
|
||||
this.posterSizes = posterSizes;
|
||||
}
|
||||
|
||||
public void setProfileSizes(List<String> profileSizes) {
|
||||
this.profileSizes = profileSizes;
|
||||
}
|
||||
|
||||
public void setLogoSizes(List<String> logoSizes) {
|
||||
this.logoSizes = logoSizes;
|
||||
}
|
||||
|
||||
public void setSecureBaseUrl(String secureBaseUrl) {
|
||||
this.secureBaseUrl = secureBaseUrl;
|
||||
}
|
||||
|
||||
public void setStillSizes(List<String> stillSizes) {
|
||||
this.stillSizes = stillSizes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the data from the passed object to this one
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
public void clone(TmdbConfiguration config) {
|
||||
backdropSizes = config.getBackdropSizes();
|
||||
baseUrl = config.getBaseUrl();
|
||||
posterSizes = config.getPosterSizes();
|
||||
profileSizes = config.getProfileSizes();
|
||||
logoSizes = config.getLogoSizes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the poster size is valid
|
||||
*
|
||||
* @param posterSize
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidPosterSize(String posterSize) {
|
||||
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return posterSizes.contains(posterSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the backdrop size is valid
|
||||
*
|
||||
* @param backdropSize
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidBackdropSize(String backdropSize) {
|
||||
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return backdropSizes.contains(backdropSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the profile size is valid
|
||||
*
|
||||
* @param profileSize
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidProfileSize(String profileSize) {
|
||||
if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return profileSizes.contains(profileSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the logo size is valid
|
||||
*
|
||||
* @param logoSize
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidLogoSize(String logoSize) {
|
||||
if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return logoSizes.contains(logoSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the size is valid for any of the images types
|
||||
*
|
||||
* @param sizeToCheck
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidSize(String sizeToCheck) {
|
||||
return isValidPosterSize(sizeToCheck)
|
||||
|| isValidBackdropSize(sizeToCheck)
|
||||
|| isValidProfileSize(sizeToCheck)
|
||||
|| isValidLogoSize(sizeToCheck);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model.change;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChangeKeyItem {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonProperty("key")
|
||||
private String key;
|
||||
@JsonProperty("items")
|
||||
private List<ChangedItem> changedItems = new ArrayList<ChangedItem>();
|
||||
private final Map<String, Object> newItems = new HashMap<String, Object>();
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public List<ChangedItem> getChangedItems() {
|
||||
return changedItems;
|
||||
}
|
||||
|
||||
public void setChangedItems(List<ChangedItem> changes) {
|
||||
this.changedItems = changes;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getNewItems() {
|
||||
return this.newItems;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setNewItems(String name, Object value) {
|
||||
this.newItems.put(name, value);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model.change;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChangedItem extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("action")
|
||||
private String action;
|
||||
@JsonProperty("time")
|
||||
private String time;
|
||||
@JsonProperty("iso_639_1")
|
||||
private String language;
|
||||
@JsonProperty("value")
|
||||
private Object value;
|
||||
private final Map<String, Object> newItems = new HashMap<String, Object>();
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getNewItems() {
|
||||
return this.newItems;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void setNewItems(String name, Object value) {
|
||||
this.newItems.put(name, value);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model.change;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
|
||||
public class ChangedMedia extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("adult")
|
||||
private boolean adult;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isAdult() {
|
||||
return adult;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAdult(boolean adult) {
|
||||
this.adult = adult;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model.change;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
|
||||
public class ChangedMovie extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("adult")
|
||||
private boolean adult;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isAdult() {
|
||||
return adult;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAdult(boolean adult) {
|
||||
this.adult = adult;
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation;private either version 3 of the License;private or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful;private
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model.comparator;
|
||||
|
||||
import com.omertron.themoviedbapi.model.person.PersonCredit;
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Compare two PersonCredits by date
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class PersonCreditDateComparator implements Comparator<PersonCredit>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Pattern YEAR_PATTERN = Pattern.compile("(?:.*?)(\\d{4})(?:.*?)");
|
||||
private final boolean ascending;
|
||||
|
||||
public PersonCreditDateComparator() {
|
||||
this.ascending = Boolean.FALSE;
|
||||
}
|
||||
|
||||
public PersonCreditDateComparator(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(PersonCredit pc1, PersonCredit pc2) {
|
||||
return compare(pc1, pc2, ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two PersonCredits based on the respective years
|
||||
*
|
||||
* @param pc1
|
||||
* @param pc2
|
||||
* @param ascending
|
||||
* @return
|
||||
*/
|
||||
public int compare(PersonCredit pc1, PersonCredit pc2, boolean ascending) {
|
||||
boolean valid1 = StringUtils.isNotBlank(pc1.getReleaseDate());
|
||||
boolean valid2 = StringUtils.isNotBlank(pc2.getReleaseDate());
|
||||
|
||||
if (!valid1 && !valid2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!valid1) {
|
||||
return ascending ? -1 : 1;
|
||||
}
|
||||
|
||||
if (!valid2) {
|
||||
return ascending ? 1 : -1;
|
||||
}
|
||||
|
||||
int year1 = extractYear(pc1.getReleaseDate());
|
||||
int year2 = extractYear(pc2.getReleaseDate());
|
||||
return ascending ? year1 - year2 : year2 - year1;
|
||||
}
|
||||
|
||||
/**
|
||||
* locate a 4 digit year in a date string
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
private static int extractYear(String date) {
|
||||
int year = 0;
|
||||
Matcher m = YEAR_PATTERN.matcher(date);
|
||||
if (m.find()) {
|
||||
year = Integer.parseInt(m.group(1));
|
||||
}
|
||||
|
||||
// Give up and return 0
|
||||
return year;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.omertron.themoviedbapi.model.tv;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.Genre;
|
||||
import com.omertron.themoviedbapi.model2.Genre;
|
||||
import com.omertron.themoviedbapi.model.person.Person;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
+2
-1
@@ -17,9 +17,10 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import com.omertron.themoviedbapi.model.AbstractIdName;
|
||||
|
||||
/**
|
||||
* @author stuart.boston
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2.list;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model2.movie;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.Language;
|
||||
import com.omertron.themoviedbapi.model2.Genre;
|
||||
import com.omertron.themoviedbapi.model.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.person.PersonCast;
|
||||
|
||||
+2
-1
@@ -17,9 +17,10 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2.movie;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import com.omertron.themoviedbapi.model.AbstractIdName;
|
||||
|
||||
/**
|
||||
* @author stuart.boston
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2.movie;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2.movie;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.Genre;
|
||||
import com.omertron.themoviedbapi.model2.Genre;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.change.ChangedMedia;
|
||||
|
||||
public class WrapperMediaChanges extends AbstractWrapperAll {
|
||||
|
||||
@JsonProperty("results")
|
||||
private List<ChangedMedia> results;
|
||||
|
||||
public List<ChangedMedia> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(List<ChangedMedia> results) {
|
||||
this.results = results;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.change.ChangedMovie;
|
||||
|
||||
public class WrapperMovieChanges extends AbstractWrapperAll {
|
||||
|
||||
@JsonProperty("results")
|
||||
private List<ChangedMovie> results;
|
||||
|
||||
public List<ChangedMovie> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(List<ChangedMovie> results) {
|
||||
this.results = results;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2015 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.person.Person;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class WrapperPersonList extends AbstractWrapperAll {
|
||||
|
||||
@JsonProperty("results")
|
||||
private List<Person> personList;
|
||||
|
||||
public List<Person> getPersonList() {
|
||||
return personList;
|
||||
}
|
||||
|
||||
public void setPersonList(List<Person> personList) {
|
||||
this.personList = personList;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import com.omertron.themoviedbapi.model.Trailer;
|
||||
import com.omertron.themoviedbapi.model2.movie.Trailer;
|
||||
import com.omertron.themoviedbapi.model2.movie.Video;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.methods;
|
||||
|
||||
import com.omertron.themoviedbapi.AbstractTests;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.model.Genre;
|
||||
import com.omertron.themoviedbapi.model2.Genre;
|
||||
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import java.util.List;
|
||||
|
||||
Reference in New Issue
Block a user