From b5b84cc962f1ba6e1f8778b5d915c8f6e954296a Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 25 Aug 2015 14:47:15 +0100 Subject: [PATCH] Add more information to CollectionInfo --- .../omertron/themoviedbapi/TheMovieDbApi.java | 3 +- .../themoviedbapi/methods/AbstractMethod.java | 6 - .../themoviedbapi/methods/TmdbSearch.java | 6 +- .../model/collection/Collection.java | 134 ------------------ .../model/collection/CollectionInfo.java | 7 +- .../themoviedbapi/model/movie/MovieInfo.java | 8 +- .../themoviedbapi/methods/TmdbSearchTest.java | 4 +- 7 files changed, 14 insertions(+), 154 deletions(-) delete mode 100644 src/main/java/com/omertron/themoviedbapi/model/collection/Collection.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index bef7e1a9c..f74c7adf1 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -55,7 +55,6 @@ import com.omertron.themoviedbapi.model.authentication.TokenAuthorisation; import com.omertron.themoviedbapi.model.authentication.TokenSession; import com.omertron.themoviedbapi.model.change.ChangeKeyItem; import com.omertron.themoviedbapi.model.change.ChangeListItem; -import com.omertron.themoviedbapi.model.collection.Collection; import com.omertron.themoviedbapi.model.collection.CollectionInfo; import com.omertron.themoviedbapi.model.company.Company; import com.omertron.themoviedbapi.model.config.Configuration; @@ -1327,7 +1326,7 @@ public class TheMovieDbApi { * @return * @throws MovieDbException */ - public ResultList searchCollection(String query, Integer page, String language) throws MovieDbException { + public ResultList searchCollection(String query, Integer page, String language) throws MovieDbException { return tmdbSearch.searchCollection(query, page, language); } diff --git a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java index 7e4f4dcd3..1229f8d3f 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java @@ -25,9 +25,7 @@ import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.artwork.ArtworkMedia; import com.omertron.themoviedbapi.model.change.ChangeKeyItem; import com.omertron.themoviedbapi.model.change.ChangeListItem; -import com.omertron.themoviedbapi.model.collection.Collection; import com.omertron.themoviedbapi.model.company.Company; -import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.list.UserList; import com.omertron.themoviedbapi.model.media.AlternativeTitle; import com.omertron.themoviedbapi.model.movie.MovieBasic; @@ -78,10 +76,6 @@ public class AbstractMethod { }); TYPE_REFS.put(Company.class, new TypeReference>() { }); - TYPE_REFS.put(Collection.class, new TypeReference>() { - }); - TYPE_REFS.put(Keyword.class, new TypeReference>() { - }); TYPE_REFS.put(MovieInfo.class, new TypeReference>() { }); TYPE_REFS.put(PersonInfo.class, new TypeReference>() { diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java index ae578d797..dcfd301ee 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java @@ -22,11 +22,11 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.enumeration.SearchType; import static com.omertron.themoviedbapi.methods.AbstractMethod.MAPPER; -import com.omertron.themoviedbapi.model.collection.Collection; import com.omertron.themoviedbapi.model.company.Company; import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.list.UserList; import com.omertron.themoviedbapi.model.media.MediaBasic; +import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.model.movie.MovieInfo; import com.omertron.themoviedbapi.model.person.PersonFind; import com.omertron.themoviedbapi.model.tv.TVBasic; @@ -92,14 +92,14 @@ public class TmdbSearch extends AbstractMethod { * @return * @throws MovieDbException */ - public ResultList searchCollection(String query, Integer page, String language) throws MovieDbException { + public ResultList searchCollection(String query, Integer page, String language) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.QUERY, query); parameters.add(Param.PAGE, page); parameters.add(Param.LANGUAGE, language); URL url = new ApiUrl(apiKey, MethodBase.SEARCH).subMethod(MethodSub.COLLECTION).buildUrl(parameters); - WrapperGenericList wrapper = processWrapper(getTypeReference(Collection.class), url, "collection"); + WrapperGenericList wrapper = processWrapper(getTypeReference(MovieBasic.class), url, "collection"); return wrapper.getResultsList(); } diff --git a/src/main/java/com/omertron/themoviedbapi/model/collection/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/collection/Collection.java deleted file mode 100644 index 8fedc56ff..000000000 --- a/src/main/java/com/omertron/themoviedbapi/model/collection/Collection.java +++ /dev/null @@ -1,134 +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 . - * - */ -package com.omertron.themoviedbapi.model.collection; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import com.omertron.themoviedbapi.interfaces.Identification; -import com.omertron.themoviedbapi.model.AbstractJsonMapping; -import java.io.Serializable; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -/** - * @author stuart.boston - */ -@JsonRootName("collection") -public class Collection extends AbstractJsonMapping implements Serializable, Identification { - - private static final long serialVersionUID = 100L; - - @JsonProperty("id") - private int id; - @JsonProperty("title") - private String title; - @JsonProperty("name") - private String name; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("backdrop_path") - private String backdropPath; - @JsonProperty("release_date") - private String releaseDate; - - public String getBackdropPath() { - return backdropPath; - } - - @Override - public int getId() { - return id; - } - - public String getPosterPath() { - return posterPath; - } - - public String getReleaseDate() { - return releaseDate; - } - - public String getTitle() { - if (StringUtils.isBlank(title)) { - return name; - } - return title; - } - - public String getName() { - if (StringUtils.isBlank(name)) { - return title; - } - return name; - } - - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - @Override - public void setId(int id) { - this.id = id; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Collection) { - final Collection other = (Collection) obj; - return new EqualsBuilder() - .append(id, other.id) - .append(name, other.name) - .append(title, other.title) - .append(backdropPath, other.backdropPath) - .isEquals(); - } else { - return false; - } - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .append(id) - .append(backdropPath) - .append(title) - .append(name) - .append(posterPath) - .append(releaseDate) - .toHashCode(); - } -} diff --git a/src/main/java/com/omertron/themoviedbapi/model/collection/CollectionInfo.java b/src/main/java/com/omertron/themoviedbapi/model/collection/CollectionInfo.java index d1c77bbe2..62f1786e1 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/collection/CollectionInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/collection/CollectionInfo.java @@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.model.collection; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.interfaces.Identification; import com.omertron.themoviedbapi.model.AbstractJsonMapping; +import com.omertron.themoviedbapi.model.movie.MovieBasic; import java.io.Serializable; import java.util.ArrayList; @@ -45,7 +46,7 @@ public class CollectionInfo extends AbstractJsonMapping implements Serializable, @JsonProperty("backdrop_path") private String backdropPath; @JsonProperty("parts") - private List parts = new ArrayList<>(); + private List parts = new ArrayList<>(); public String getBackdropPath() { return backdropPath; @@ -64,7 +65,7 @@ public class CollectionInfo extends AbstractJsonMapping implements Serializable, return overview; } - public List getParts() { + public List getParts() { return parts; } @@ -89,7 +90,7 @@ public class CollectionInfo extends AbstractJsonMapping implements Serializable, this.overview = overview; } - public void setParts(List parts) { + public void setParts(List parts) { this.parts = parts; } diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java index d60a7bd2d..9870e7cb0 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java @@ -31,7 +31,7 @@ import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Language; import com.omertron.themoviedbapi.model.artwork.Artwork; import com.omertron.themoviedbapi.model.change.ChangeKeyItem; -import com.omertron.themoviedbapi.model.collection.Collection; +import com.omertron.themoviedbapi.model.collection.CollectionInfo; import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.list.UserList; import com.omertron.themoviedbapi.model.credits.MediaCreditCast; @@ -62,7 +62,7 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio private static final long serialVersionUID = 100L; @JsonProperty("belongs_to_collection") - private Collection belongsToCollection; + private CollectionInfo belongsToCollection; @JsonProperty("budget") private long budget; @JsonProperty("genres") @@ -99,7 +99,7 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio private List changes = Collections.emptyList(); // - public Collection getBelongsToCollection() { + public CollectionInfo getBelongsToCollection() { return belongsToCollection; } @@ -145,7 +145,7 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio // // - public void setBelongsToCollection(Collection belongsToCollection) { + public void setBelongsToCollection(CollectionInfo belongsToCollection) { this.belongsToCollection = belongsToCollection; } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java index 9d8ccfdc2..f5c989e47 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java @@ -24,11 +24,11 @@ import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.TestSuite; import com.omertron.themoviedbapi.enumeration.MediaType; import com.omertron.themoviedbapi.enumeration.SearchType; -import com.omertron.themoviedbapi.model.collection.Collection; import com.omertron.themoviedbapi.model.company.Company; import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.list.UserList; import com.omertron.themoviedbapi.model.media.MediaBasic; +import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.model.movie.MovieInfo; import com.omertron.themoviedbapi.model.person.PersonFind; import com.omertron.themoviedbapi.model.tv.TVBasic; @@ -77,7 +77,7 @@ public class TmdbSearchTest extends AbstractTests { LOG.info("searchCollection"); String query = "batman"; int page = 0; - ResultList result = instance.searchCollection(query, page, LANGUAGE_DEFAULT); + ResultList result = instance.searchCollection(query, page, LANGUAGE_DEFAULT); TestSuite.test(result, "Collection"); TestSuite.testId(result, 263, "Collection"); }