Add AppendToResponse interfaces
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ package com.omertron.themoviedbapi.interfaces;
|
||||
* Interface to indicate that the object has append to response methods
|
||||
*
|
||||
* @author Stuart
|
||||
* @param <T> Method for Append To Response
|
||||
* @param <AppendToResponseMethod> Method for Append To Response
|
||||
*/
|
||||
public interface AppendToResponse<T> {
|
||||
public interface AppendToResponse<AppendToResponseMethod> {
|
||||
|
||||
boolean hasMethod(T method);
|
||||
boolean hasMethod(AppendToResponseMethod method);
|
||||
|
||||
}
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.interfaces;
|
||||
|
||||
public interface AppendToResponseMethod {
|
||||
|
||||
String getPropertyString();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<MovieMethod> {
|
||||
|
||||
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<Language> 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<MovieMethod> methods = EnumSet.noneOf(MovieMethod.class);
|
||||
// AppendToResponse Properties
|
||||
@@ -131,39 +105,6 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, Iden
|
||||
private List<ChangeKeyItem> changes = Collections.emptyList();
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Getter methods">
|
||||
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;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
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
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
|
||||
@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();
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
private void addMethod(MovieMethod method) {
|
||||
methods.add(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMethod(MovieMethod method) {
|
||||
return methods.contains(method);
|
||||
}
|
||||
|
||||
@@ -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<PeopleMethod> {
|
||||
|
||||
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 {
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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<TVMethod> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user