Remove unused wrappers

This commit is contained in:
Stuart Boston
2015-03-04 12:59:35 +00:00
parent 590852c5ac
commit ccd6f7411c
9 changed files with 57 additions and 335 deletions
@@ -46,7 +46,6 @@ import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
@@ -80,7 +79,8 @@ public class TmdbMovies extends AbstractMethod {
*
* It will return the single highest rated poster and backdrop.
*
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
* found.
*
* @param movieId
* @param language
@@ -112,7 +112,8 @@ public class TmdbMovies extends AbstractMethod {
*
* It will return the single highest rated poster and backdrop.
*
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
* found.
*
* @param imdbId
* @param language
@@ -141,8 +142,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method lets a user get the status of whether or not the movie has been rated or added to their favourite or movie watch
* list.
* This method lets a user get the status of whether or not the movie has
* been rated or added to their favourite or movie watch list.
*
* A valid session id is required.
*
@@ -167,7 +168,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the alternative titles we have for a particular movie.
* This method is used to retrieve all of the alternative titles we have for
* a particular movie.
*
* @param movieId
* @param country
@@ -216,7 +218,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method should be used when youre wanting to retrieve all of the images for a particular movie.
* This method should be used when youre wanting to retrieve all of the
* images for a particular movie.
*
* @param movieId
* @param language
@@ -244,7 +247,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the keywords that have been added to a particular movie.
* This method is used to retrieve all of the keywords that have been added
* to a particular movie.
*
* Currently, only English keywords exist.
*
@@ -272,7 +276,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the release and certification data we have for a specific movie.
* This method is used to retrieve all of the release and certification data
* we have for a specific movie.
*
* @param movieId
* @param language
@@ -300,7 +305,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the trailers for a particular movie.
* This method is used to retrieve all of the trailers for a particular
* movie.
*
* Supported sites are YouTube and QuickTime.
*
@@ -330,7 +336,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve a list of the available translations for a specific movie.
* This method is used to retrieve a list of the available translations for
* a specific movie.
*
* @param movieId
* @param appendToResponse
@@ -356,9 +363,11 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* The similar movies method will let you retrieve the similar movies for a particular movie.
* The similar movies method will let you retrieve the similar movies for a
* particular movie.
*
* This data is created dynamically but with the help of users votes on TMDb.
* This data is created dynamically but with the help of users votes on
* TMDb.
*
* The data is much better with movies that have more keywords
*
@@ -377,16 +386,8 @@ public class TmdbMovies extends AbstractMethod {
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMovie wrapper = MAPPER.readValue(webpage, WrapperMovie.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get similar movies", url, ex);
}
WrapperGenericList<MovieDb> wrapper = processWrapper(getTypeReference(MovieDb.class), url, "similar movies");
return wrapper.getTmdbResultsList();
}
/**
@@ -445,7 +446,8 @@ public class TmdbMovies extends AbstractMethod {
*
* By default, only the last 24 hours of changes are returned.
*
* The maximum number of days that can be returned in a single request is 14.
* The maximum number of days that can be returned in a single request is
* 14.
*
* The language is present on fields that are translatable.
*
@@ -542,23 +544,15 @@ public class TmdbMovies extends AbstractMethod {
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.UPCOMING).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMovie wrapper = MAPPER.readValue(webpage, WrapperMovie.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get upcoming movies", url, ex);
}
WrapperGenericList<MovieDb> wrapper = processWrapper(getTypeReference(MovieDb.class), url, "upcoming movies");
return wrapper.getTmdbResultsList();
}
/**
* This method is used to retrieve the movies currently in theatres.
*
* This is a curated list that will normally contain 100 movies. The default response will return 20 movies.
* This is a curated list that will normally contain 100 movies. The default
* response will return 20 movies.
*
* @param language
* @param page
@@ -571,16 +565,8 @@ public class TmdbMovies extends AbstractMethod {
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.NOW_PLAYING).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMovie wrapper = MAPPER.readValue(webpage, WrapperMovie.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get now playing movies", url, ex);
}
WrapperGenericList<MovieDb> wrapper = processWrapper(getTypeReference(MovieDb.class), url, "now playing movies");
return wrapper.getTmdbResultsList();
}
/**
@@ -599,20 +585,13 @@ public class TmdbMovies extends AbstractMethod {
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.POPULAR).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMovie wrapper = MAPPER.readValue(webpage, WrapperMovie.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get popular movie list", url, ex);
}
WrapperGenericList<MovieDb> wrapper = processWrapper(getTypeReference(MovieDb.class), url, "popular movie list");
return wrapper.getTmdbResultsList();
}
/**
* This method is used to retrieve the top rated movies that have over 10 votes on TMDb.
* This method is used to retrieve the top rated movies that have over 10
* votes on TMDb.
*
* The default response will return 20 movies.
*
@@ -627,16 +606,8 @@ public class TmdbMovies extends AbstractMethod {
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.TOP_RATED).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMovie wrapper = MAPPER.readValue(webpage, WrapperMovie.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get top rated movies", url, ex);
}
WrapperGenericList<MovieDb> wrapper = processWrapper(getTypeReference(MovieDb.class), url, "top rated movies");
return wrapper.getTmdbResultsList();
}
}
@@ -20,6 +20,7 @@
package com.omertron.themoviedbapi.model.movie;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model.Language;
@@ -32,13 +33,12 @@ import com.omertron.themoviedbapi.model.media.MediaCreditCrew;
import com.omertron.themoviedbapi.model.media.MediaCreditList;
import com.omertron.themoviedbapi.model.review.Review;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
import com.omertron.themoviedbapi.wrapper.WrapperReviews;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
import com.omertron.themoviedbapi.wrapper.WrapperUserList;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import java.util.List;
import org.apache.commons.lang3.builder.EqualsBuilder;
@@ -117,12 +117,10 @@ public class MovieDb extends AbstractJsonMapping {
private WrapperVideos trailers;
@JsonProperty("translations")
private WrapperTranslations translations;
@JsonProperty("similar_movies")
private WrapperMovie similarMovies;
private List<MovieDb> similarMovies;
@JsonProperty("reviews")
private WrapperReviews reviews;
@JsonProperty("lists")
private WrapperUserList lists;
private List<UserList> lists;
@JsonProperty("video")
private Boolean video = null;
@@ -372,11 +370,11 @@ public class MovieDb extends AbstractJsonMapping {
}
public List<MovieDb> getSimilarMovies() {
return similarMovies.getMovies();
return similarMovies;
}
public List<UserList> getLists() {
return lists.getUserList();
return lists;
}
public List<Review> getReviews() {
@@ -413,12 +411,14 @@ public class MovieDb extends AbstractJsonMapping {
this.translations = translations;
}
public void setSimilarMovies(WrapperMovie similarMovies) {
this.similarMovies = similarMovies;
@JsonSetter("similar_movies")
public void setSimilarMovies(WrapperGenericList<MovieDb> similarMovies) {
this.similarMovies = similarMovies.getResults();
}
public void setLists(WrapperUserList lists) {
this.lists = lists;
@JsonSetter("lists")
public void setLists(WrapperGenericList<UserList> lists) {
this.lists = lists.getResults();
}
public void setReviews(WrapperReviews reviews) {
@@ -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.collection.Collection;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperCollection extends AbstractWrapperAll {
@JsonProperty("results")
private List<Collection> results;
public List<Collection> getResults() {
return results;
}
public void setResults(List<Collection> 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.company.Company;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperCompany extends AbstractWrapperAll {
@JsonProperty("results")
private List<Company> results;
public List<Company> getResults() {
return results;
}
public void setResults(List<Company> 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.movie.MovieBasic;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperCompanyMovies extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieBasic> results;
public List<MovieBasic> getResults() {
return results;
}
public void setResults(List<MovieBasic> results) {
this.results = results;
}
}
@@ -21,6 +21,7 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.io.Serializable;
import java.util.List;
@@ -43,4 +44,10 @@ public class WrapperGenericList<T> extends AbstractWrapperAll implements Seriali
public void setResults(List<T> results) {
this.results = results;
}
public TmdbResultsList<T> getTmdbResultsList() {
TmdbResultsList<T> resultsList = new TmdbResultsList<T>(results);
resultsList.copyWrapper(this);
return resultsList;
}
}
@@ -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.keyword.Keyword;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperKeywords extends AbstractWrapperAll {
@JsonProperty("results")
private List<Keyword> results;
public List<Keyword> getResults() {
return results;
}
public void setResults(List<Keyword> results) {
this.results = results;
}
}
@@ -1,44 +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.movie.MovieDb;
import java.io.Serializable;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperMovie extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results")
private List<MovieDb> movies;
public List<MovieDb> getMovies() {
return movies;
}
public void setMovies(List<MovieDb> movies) {
this.movies = movies;
}
}
@@ -1,44 +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.list.UserList;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperUserList extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results")
private List<UserList> userList;
public List<UserList> getUserList() {
return userList;
}
public void setUserList(List<UserList> userList) {
this.userList = userList;
}
}