diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java b/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java index 9ddc5d8ca..e91d72bbf 100644 --- a/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java @@ -19,6 +19,7 @@ */ package com.omertron.themoviedbapi.enumeration; +import com.omertron.themoviedbapi.interfaces.AppendToResponseMethod; import org.apache.commons.lang3.StringUtils; /** @@ -26,7 +27,7 @@ import org.apache.commons.lang3.StringUtils; * * @author Stuart */ -public enum MovieMethod { +public enum MovieMethod implements AppendToResponseMethod { ALTERNATIVE_TITLES, CHANGES, @@ -45,6 +46,7 @@ public enum MovieMethod { * * @return */ + @Override public String getPropertyString() { return this.name().toLowerCase(); } diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/PeopleMethod.java b/src/main/java/com/omertron/themoviedbapi/enumeration/PeopleMethod.java index 49539afd5..d6362481c 100644 --- a/src/main/java/com/omertron/themoviedbapi/enumeration/PeopleMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/enumeration/PeopleMethod.java @@ -19,6 +19,7 @@ */ package com.omertron.themoviedbapi.enumeration; +import com.omertron.themoviedbapi.interfaces.AppendToResponseMethod; import org.apache.commons.lang3.StringUtils; /** @@ -26,7 +27,7 @@ import org.apache.commons.lang3.StringUtils; * * @author Stuart */ -public enum PeopleMethod { +public enum PeopleMethod implements AppendToResponseMethod { CHANGES, COMBINED_CREDITS, @@ -41,6 +42,7 @@ public enum PeopleMethod { * * @return */ + @Override public String getPropertyString() { return this.name().toLowerCase(); } diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/TVMethod.java b/src/main/java/com/omertron/themoviedbapi/enumeration/TVMethod.java index 112c0224f..c37ba7486 100644 --- a/src/main/java/com/omertron/themoviedbapi/enumeration/TVMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/enumeration/TVMethod.java @@ -19,6 +19,7 @@ */ package com.omertron.themoviedbapi.enumeration; +import com.omertron.themoviedbapi.interfaces.AppendToResponseMethod; import org.apache.commons.lang3.StringUtils; /** @@ -26,7 +27,7 @@ import org.apache.commons.lang3.StringUtils; * * @author Stuart */ -public enum TVMethod { +public enum TVMethod implements AppendToResponseMethod { ALTERNATIVE_TITLES, CHANGES, @@ -44,6 +45,7 @@ public enum TVMethod { * * @return */ + @Override public String getPropertyString() { return this.name().toLowerCase(); } diff --git a/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponse.java b/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponse.java index 2241a87ae..8c8158cc9 100644 --- a/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponse.java +++ b/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponse.java @@ -23,10 +23,10 @@ package com.omertron.themoviedbapi.interfaces; * Interface to indicate that the object has append to response methods * * @author Stuart - * @param Method for Append To Response + * @param Method for Append To Response */ -public interface AppendToResponse { +public interface AppendToResponse { - boolean hasMethod(T method); + boolean hasMethod(AppendToResponseMethod method); } diff --git a/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponseMethod.java b/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponseMethod.java new file mode 100644 index 000000000..0976f1538 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/interfaces/AppendToResponseMethod.java @@ -0,0 +1,25 @@ +/* + * 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.interfaces; + +public interface AppendToResponseMethod { + + String getPropertyString(); +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieBasic.java b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieBasic.java index 58272af09..a6c61cdf3 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieBasic.java +++ b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieBasic.java @@ -42,9 +42,9 @@ public class MovieBasic extends MediaBasic implements Serializable { @JsonProperty("title") private String title; @JsonProperty("video") - private boolean video; + private Boolean video = null; @JsonProperty("rating") - private float rating = -1f; + private float userRating = -1f; public MovieBasic() { super.setMediaType(MediaType.MOVIE); @@ -90,11 +90,11 @@ public class MovieBasic extends MediaBasic implements Serializable { this.video = video; } - public float getRating() { - return rating; + public float getUserRating() { + return userRating; } - public void setRating(float rating) { - this.rating = rating; + public void setUserRating(float userRating) { + this.userRating = userRating; } } 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 a7154370e..b5fca45aa 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java @@ -25,8 +25,8 @@ import com.omertron.themoviedbapi.model.media.AlternativeTitle; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.omertron.themoviedbapi.enumeration.MovieMethod; +import com.omertron.themoviedbapi.interfaces.AppendToResponse; import com.omertron.themoviedbapi.interfaces.Identification; -import com.omertron.themoviedbapi.model.AbstractJsonMapping; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Language; import com.omertron.themoviedbapi.model.artwork.Artwork; @@ -51,34 +51,16 @@ import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Set; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; /** * Movie Bean * * @author stuart.boston */ -public class MovieInfo extends AbstractJsonMapping implements Serializable, Identification { +public class MovieInfo extends MovieBasic implements Serializable, Identification, AppendToResponse { private static final long serialVersionUID = 4L; - @JsonProperty("backdrop_path") - private String backdropPath; - @JsonProperty("id") - private int id; - @JsonProperty("original_title") - private String originalTitle; - @JsonProperty("popularity") - private float popularity; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("release_date") - private String releaseDate; - @JsonProperty("title") - private String title; - @JsonProperty("adult") - private boolean adult; @JsonProperty("belongs_to_collection") private Collection belongsToCollection; @JsonProperty("budget") @@ -105,16 +87,8 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, Iden private List spokenLanguages = Collections.emptyList(); @JsonProperty("tagline") private String tagline; - @JsonProperty("rating") - private float userRating; - @JsonProperty("vote_average") - private float voteAverage; - @JsonProperty("vote_count") - private int voteCount; @JsonProperty("status") private String status; - @JsonProperty("video") - private Boolean video = null; // AppendToResponse private final Set methods = EnumSet.noneOf(MovieMethod.class); // AppendToResponse Properties @@ -131,39 +105,6 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, Iden private List changes = Collections.emptyList(); // - public String getBackdropPath() { - return backdropPath; - } - - @Override - public int getId() { - return id; - } - - public String getOriginalTitle() { - return originalTitle; - } - - public float getPopularity() { - return popularity; - } - - public String getPosterPath() { - return posterPath; - } - - public String getReleaseDate() { - return releaseDate; - } - - public String getTitle() { - return title; - } - - public boolean isAdult() { - return adult; - } - public Collection getBelongsToCollection() { return belongsToCollection; } @@ -212,65 +153,16 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, Iden return tagline; } - public float getVoteAverage() { - return voteAverage; - } - - public int getVoteCount() { - return voteCount; - } - public String getStatus() { return status; } - public float getUserRating() { - return userRating; - } - - public Boolean getVideo() { - return video; - } - public String getOriginalLanguage() { return originalLanguage; } // // - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - @Override - public void setId(int id) { - this.id = id; - } - - public void setOriginalTitle(String originalTitle) { - this.originalTitle = originalTitle; - } - - public void setPopularity(float popularity) { - this.popularity = popularity; - } - - 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 setAdult(boolean adult) { - this.adult = adult; - } - public void setBelongsToCollection(Collection belongsToCollection) { this.belongsToCollection = belongsToCollection; } @@ -319,26 +211,10 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, Iden this.tagline = tagline; } - public void setVoteAverage(float voteAverage) { - this.voteAverage = voteAverage; - } - - public void setVoteCount(int voteCount) { - this.voteCount = voteCount; - } - public void setStatus(String status) { this.status = status; } - public void setUserRating(float userRating) { - this.userRating = userRating; - } - - public void setVideo(Boolean video) { - this.video = video; - } - public void setOriginalLanguage(String originalLanguage) { this.originalLanguage = originalLanguage; } @@ -461,35 +337,11 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, Iden } // - // - @Override - public boolean equals(Object obj) { - if (obj instanceof MovieInfo) { - final MovieInfo other = (MovieInfo) obj; - return new EqualsBuilder() - .append(id, other.id) - .append(imdbID, other.imdbID) - .append(runtime, other.runtime) - .isEquals(); - } else { - return false; - } - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .append(id) - .append(imdbID) - .append(runtime) - .toHashCode(); - } - // - private void addMethod(MovieMethod method) { methods.add(method); } + @Override public boolean hasMethod(MovieMethod method) { return methods.contains(method); } diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java index 68bf86d8a..14f3eee4f 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java @@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.model.person; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.omertron.themoviedbapi.enumeration.PeopleMethod; +import com.omertron.themoviedbapi.interfaces.AppendToResponse; import com.omertron.themoviedbapi.model.artwork.Artwork; import com.omertron.themoviedbapi.model.artwork.ArtworkMedia; import com.omertron.themoviedbapi.model.change.ChangeKeyItem; @@ -39,7 +40,7 @@ import java.util.Set; /** * @author stuart.boston */ -public class PersonInfo extends PersonBasic implements Serializable { +public class PersonInfo extends PersonBasic implements Serializable, AppendToResponse { private static final long serialVersionUID = 4L; @@ -150,6 +151,7 @@ public class PersonInfo extends PersonBasic implements Serializable { methods.add(method); } + @Override public boolean hasMethod(PeopleMethod method) { return methods.contains(method); } @@ -218,5 +220,4 @@ public class PersonInfo extends PersonBasic implements Serializable { } // - } diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java index b7c9354a6..190bdeac3 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java @@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.model.tv; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.omertron.themoviedbapi.enumeration.TVMethod; +import com.omertron.themoviedbapi.interfaces.AppendToResponse; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.artwork.Artwork; import com.omertron.themoviedbapi.model.change.ChangeKeyItem; @@ -49,7 +50,7 @@ import java.util.Set; * * @author Stuart */ -public class TVInfo extends TVBasic implements Serializable { +public class TVInfo extends TVBasic implements Serializable, AppendToResponse { private static final long serialVersionUID = 4L; @@ -233,6 +234,7 @@ public class TVInfo extends TVBasic implements Serializable { methods.add(method); } + @Override public boolean hasMethod(TVMethod method) { return methods.contains(method); }