25 Commits

Author SHA1 Message Date
Omertron 8068b9ac45 [maven-release-plugin] prepare release themoviedbapi-3.7 2013-08-23 10:21:30 +02:00
Omertron a25da9aa2f Reset version 2013-08-23 10:18:48 +02:00
Omertron 7a30ab831c Updated POM versions 2013-08-23 10:13:04 +02:00
Stuart Boston f64786e506 Update tests 2013-08-22 21:32:35 +01:00
Stuart Boston a57e7eeb37 Add toString methods 2013-08-22 21:32:26 +01:00
Stuart Boston 00bdfaf6a7 Add missing properties to MovieDbList
Tidy up other code
2013-08-22 13:13:25 +01:00
Stuart Boston 064117e66d Remove unused imports 2013-08-20 21:22:32 +01:00
Stuart Boston a520c75773 Remove duplicate literals 2013-08-20 21:12:26 +01:00
Stuart Boston 259eb81f32 Remove unused fields 2013-08-20 21:12:11 +01:00
Stuart Boston 8bfe7dcc1b WebBrowser: Throw MovieDbException 2013-08-20 21:11:34 +01:00
Stuart Boston ac57816b1d Merge pull request #6 from holgerbrandl/master
"List" and "Account" implemenation
2013-08-20 20:47:24 +01:00
Stuart Boston 073331cddb Close output stream 2013-08-20 13:18:06 +01:00
Stuart Boston 0ef278e19d Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-08-20 09:01:28 +01:00
Stuart Boston d6e02bf1df Merge pull request #5 from holgerbrandl/master
implemented method to post movie ratings
2013-08-20 00:51:52 -07:00
holger fbdf744dc6 implemented method to post movie ratings 2013-08-19 14:28:28 +02:00
Stuart Boston 8478865141 Change ToString style to "short prefix" 2013-07-25 12:52:24 +01:00
Stuart Boston a98eac75dc Add dates to the wrapper where needed 2013-07-24 17:06:30 +01:00
Stuart Boston 9a237042f0 Change ToString style to "Simple" 2013-07-24 16:47:50 +01:00
Stuart Boston bb57c16fe8 Trim the string values for person to remove extra spaces 2013-07-22 13:43:54 +01:00
Stuart Boston 72186feaf9 Fixes issue #4 Company parent correctly de-serialised now 2013-07-15 09:16:16 +01:00
Stuart Boston 20349013cc Updated API-Common version 2013-06-26 16:31:47 +01:00
Stuart Boston c8e33abd59 Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-06-26 16:30:42 +01:00
Stuart Boston 940b6a007f Revert "Updated API-Common version"
This reverts commit 822ac2a5d2.
2013-06-26 16:29:46 +01:00
Stuart Boston 822ac2a5d2 Updated API-Common version 2013-06-26 16:24:24 +01:00
Omertron f2593b2754 [maven-release-plugin] prepare for next development iteration 2013-06-26 14:31:33 +02:00
43 changed files with 5577 additions and 5614 deletions
+4 -4
View File
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId> <groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId> <artifactId>themoviedbapi</artifactId>
<version>3.6</version> <version>3.7</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>API-The MovieDB</name> <name>API-The MovieDB</name>
@@ -85,17 +85,17 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>2.2.2</version> <version>2.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.2.2</version> <version>2.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.2.2</version> <version>2.2.3</version>
</dependency> </dependency>
<!--LOGGING--> <!--LOGGING-->
<dependency> <dependency>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2004-2013 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;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* @author Holger Brandl
*/
public abstract class AbstractJsonMapping implements Serializable {
private static Logger getLogger(Class<?> aClass) {
return LoggerFactory.getLogger(aClass);
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
getLogger(this.getClass()).warn(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
}
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2004-2013 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;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Account extends AbstractJsonMapping {
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
@JsonProperty("username")
private String userName;
@JsonProperty("include_adult")
private boolean includeAdult;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isIncludeAdult() {
return includeAdult;
}
public void setIncludeAdult(boolean includeAdult) {
this.includeAdult = includeAdult;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
@@ -1,114 +1,86 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; /**
import org.slf4j.Logger; * @author Stuart
import org.slf4j.LoggerFactory; */
public class AlternativeTitle implements Serializable {
/**
* private static final long serialVersionUID = 1L;
* @author Stuart
*/ /*
public class AlternativeTitle implements Serializable { * Properties
*/
private static final long serialVersionUID = 1L; @JsonProperty("iso_3166_1")
private String country;
/* @JsonProperty("title")
* Logger private String title;
*/
private static final Logger LOG = LoggerFactory.getLogger(AlternativeTitle.class); // <editor-fold defaultstate="collapsed" desc="Getter methods">
/* public String getCountry() {
* Properties return country;
*/ }
@JsonProperty("iso_3166_1")
private String country; public String getTitle() {
@JsonProperty("title") return title;
private String title; }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCountry() { // <editor-fold defaultstate="collapsed" desc="Setter methods">
return country; public void setCountry(String country) {
} this.country = country;
}
public String getTitle() {
return title; public void setTitle(String title) {
} this.title = title;
// </editor-fold> }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCountry(String country) { @Override
this.country = country; public boolean equals(Object obj) {
} if (obj == null) {
return false;
public void setTitle(String title) { }
this.title = title; if (getClass() != obj.getClass()) {
} return false;
// </editor-fold> }
final AlternativeTitle other = (AlternativeTitle) obj;
/** if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) {
* Handle unknown properties and print a message return false;
* }
* @param key if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
* @param value return false;
*/ }
@JsonAnySetter return true;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key); @Override
sb.append("' value: '").append(value).append("'"); public int hashCode() {
LOG.trace(sb.toString()); int hash = 7;
} hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0);
hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
@Override return hash;
public boolean equals(Object obj) { }
if (obj == null) { }
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AlternativeTitle other = (AlternativeTitle) obj;
if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) {
return false;
}
if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0);
hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,202 +1,171 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * The artwork type information
import org.apache.commons.lang3.builder.ToStringStyle; *
import org.slf4j.Logger; * @author Stuart
import org.slf4j.LoggerFactory; */
public class Artwork extends AbstractJsonMapping {
/**
* The artwork type information private static final long serialVersionUID = 1L;
*
* @author Stuart /*
*/ * Properties
public class Artwork implements Serializable { */
@JsonProperty("aspect_ratio")
private static final long serialVersionUID = 1L; private float aspectRatio;
@JsonProperty("file_path")
/* private String filePath;
* Logger @JsonProperty("height")
*/ private int height;
private static final Logger LOG = LoggerFactory.getLogger(Artwork.class); @JsonProperty("iso_639_1")
/* private String language;
* Properties @JsonProperty("width")
*/ private int width;
@JsonProperty("aspect_ratio") @JsonProperty("vote_average")
private float aspectRatio; private float voteAverage;
@JsonProperty("file_path") @JsonProperty("vote_count")
private String filePath; private int voteCount;
@JsonProperty("height") @JsonProperty("flag")
private int height; private String flag;
@JsonProperty("iso_639_1") private ArtworkType artworkType = ArtworkType.POSTER;
private String language;
@JsonProperty("width") // <editor-fold defaultstate="collapsed" desc="Getter methods">
private int width; public ArtworkType getArtworkType() {
@JsonProperty("vote_average") return artworkType;
private float voteAverage; }
@JsonProperty("vote_count")
private int voteCount; public float getAspectRatio() {
@JsonProperty("flag") return aspectRatio;
private String flag; }
private ArtworkType artworkType = ArtworkType.POSTER;
public String getFilePath() {
// <editor-fold defaultstate="collapsed" desc="Getter methods"> return filePath;
public ArtworkType getArtworkType() { }
return artworkType;
} public int getHeight() {
return height;
public float getAspectRatio() { }
return aspectRatio;
} public String getLanguage() {
return language;
public String getFilePath() { }
return filePath;
} public int getWidth() {
return width;
public int getHeight() { }
return height;
} public float getVoteAverage() {
return voteAverage;
public String getLanguage() { }
return language;
} public int getVoteCount() {
return voteCount;
public int getWidth() { }
return width;
} public String getFlag() {
return flag;
public float getVoteAverage() { }
return voteAverage; // </editor-fold>
}
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public int getVoteCount() { public void setArtworkType(ArtworkType artworkType) {
return voteCount; this.artworkType = artworkType;
} }
public String getFlag() { public void setAspectRatio(float aspectRatio) {
return flag; this.aspectRatio = aspectRatio;
} }
// </editor-fold> public void setFilePath(String filePath) {
this.filePath = filePath;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType; public void setHeight(int height) {
} this.height = height;
}
public void setAspectRatio(float aspectRatio) {
this.aspectRatio = aspectRatio; public void setLanguage(String language) {
} this.language = language;
}
public void setFilePath(String filePath) {
this.filePath = filePath; public void setWidth(int width) {
} this.width = width;
}
public void setHeight(int height) {
this.height = height; public void setVoteAverage(float voteAverage) {
} this.voteAverage = voteAverage;
}
public void setLanguage(String language) {
this.language = language; public void setVoteCount(int voteCount) {
} this.voteCount = voteCount;
}
public void setWidth(int width) {
this.width = width; public void setFlag(String flag) {
} this.flag = flag;
}
public void setVoteAverage(float voteAverage) { // </editor-fold>
this.voteAverage = voteAverage;
} @Override
public boolean equals(Object obj) {
public void setVoteCount(int voteCount) { if (obj == null) {
this.voteCount = voteCount; return false;
} }
if (getClass() != obj.getClass()) {
public void setFlag(String flag) { return false;
this.flag = flag; }
} final Artwork other = (Artwork) obj;
if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) {
// </editor-fold> return false;
}
/** if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) {
* Handle unknown properties and print a message return false;
* }
* @param key if (this.height != other.height) {
* @param value return false;
*/ }
@JsonAnySetter if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) {
public void handleUnknown(String key, Object value) { return false;
StringBuilder sb = new StringBuilder(); }
sb.append("Unknown property: '").append(key); if (this.width != other.width) {
sb.append("' value: '").append(value).append("'"); return false;
LOG.trace(sb.toString()); }
} if (this.artworkType != other.artworkType) {
return false;
@Override }
public boolean equals(Object obj) { return true;
if (obj == null) { }
return false;
} @Override
if (getClass() != obj.getClass()) { public int hashCode() {
return false; int hash = 3;
} hash = 71 * hash + Float.floatToIntBits(this.aspectRatio);
final Artwork other = (Artwork) obj; hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0);
if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) { hash = 71 * hash + this.height;
return false; hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0);
} hash = 71 * hash + this.width;
if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
return false; return hash;
} }
if (this.height != other.height) { }
return false;
}
if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) {
return false;
}
if (this.width != other.width) {
return false;
}
if (this.artworkType != other.artworkType) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 71 * hash + Float.floatToIntBits(this.aspectRatio);
hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0);
hash = 71 * hash + this.height;
hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0);
hash = 71 * hash + this.width;
hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,14 +1,13 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
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.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class ChangeKeyItem { public class ChangeKeyItem {
@@ -44,9 +43,4 @@ public class ChangeKeyItem {
public void setNewItems(String name, Object value) { public void setNewItems(String name, Object value) {
this.newItems.put(name, value); this.newItems.put(name, value);
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,14 +1,13 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class ChangedItem { import java.util.HashMap;
import java.util.Map;
public class ChangedItem extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@JsonProperty("id") @JsonProperty("id")
@@ -72,9 +71,4 @@ public class ChangedItem {
public void setNewItems(String name, Object value) { public void setNewItems(String name, Object value) {
this.newItems.put(name, value); this.newItems.put(name, value);
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,172 +1,140 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonRootName; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author stuart.boston
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; @JsonRootName("collection")
import org.slf4j.LoggerFactory; public class Collection extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
*
* @author stuart.boston /*
*/ * Properties
@JsonRootName("collection") */
public class Collection implements Serializable { @JsonProperty("id")
private int id;
private static final long serialVersionUID = 1L; @JsonProperty("title")
/* private String title;
* Logger @JsonProperty("name")
*/ private String name;
private static final Logger LOG = LoggerFactory.getLogger(Collection.class); @JsonProperty("poster_path")
/* private String posterPath;
* Properties @JsonProperty("backdrop_path")
*/ private String backdropPath;
@JsonProperty("id") @JsonProperty("release_date")
private int id; private String releaseDate;
@JsonProperty("title")
private String title; //<editor-fold defaultstate="collapsed" desc="Getter methods">
@JsonProperty("name") public String getBackdropPath() {
private String name; return backdropPath;
@JsonProperty("poster_path") }
private String posterPath;
@JsonProperty("backdrop_path") public int getId() {
private String backdropPath; return id;
@JsonProperty("release_date") }
private String releaseDate;
public String getPosterPath() {
//<editor-fold defaultstate="collapsed" desc="Getter methods"> return posterPath;
public String getBackdropPath() { }
return backdropPath;
} public String getReleaseDate() {
return releaseDate;
public int getId() { }
return id;
} public String getTitle() {
if (StringUtils.isBlank(title)) {
public String getPosterPath() { return name;
return posterPath; }
} return title;
}
public String getReleaseDate() {
return releaseDate; public String getName() {
} if (StringUtils.isBlank(name)) {
return title;
public String getTitle() { }
if (StringUtils.isBlank(title)) { return name;
return name; }
}
return title; public void setBackdropPath(String backdropPath) {
} this.backdropPath = backdropPath;
}
public String getName() {
if (StringUtils.isBlank(name)) { public void setId(int id) {
return title; this.id = id;
} }
return name;
} public void setPosterPath(String posterPath) {
//</editor-fold> this.posterPath = posterPath;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setReleaseDate(String releaseDate) {
this.backdropPath = backdropPath; this.releaseDate = releaseDate;
} }
public void setId(int id) { public void setTitle(String title) {
this.id = id; this.title = title;
} }
public void setPosterPath(String posterPath) { public void setName(String name) {
this.posterPath = posterPath; this.name = name;
} }
public void setReleaseDate(String releaseDate) { @Override
this.releaseDate = releaseDate; public boolean equals(Object obj) {
} if (obj == null) {
return false;
public void setTitle(String title) { }
this.title = title; if (getClass() != obj.getClass()) {
} return false;
}
public void setName(String name) { final Collection other = (Collection) obj;
this.name = name; if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) {
} return false;
//</editor-fold> }
if (this.id != other.id) {
/** return false;
* Handle unknown properties and print a message }
* if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
* @param key return false;
* @param value }
*/ if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
@JsonAnySetter return false;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); return true;
sb.append("Unknown property: '").append(key); }
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString()); @Override
} public int hashCode() {
int hash = 7;
@Override hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
public boolean equals(Object obj) { hash = 19 * hash + this.id;
if (obj == null) { hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
return false; hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
if (getClass() != obj.getClass()) { hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return false; return hash;
} }
final Collection other = (Collection) obj; }
if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) {
return false;
}
if (this.id != other.id) {
return false;
}
if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
hash = 19 * hash + this.id;
hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -19,27 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class CollectionInfo implements Serializable { public class CollectionInfo extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -80,9 +71,7 @@ public class CollectionInfo implements Serializable {
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -106,24 +95,4 @@ public class CollectionInfo implements Serializable {
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,135 +1,113 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * Company information
import org.apache.commons.lang3.builder.ToStringStyle; *
import org.slf4j.Logger; * @author Stuart
import org.slf4j.LoggerFactory; */
public class Company extends AbstractJsonMapping {
/**
* Company information private static final long serialVersionUID = 1L;
* private static final String DEFAULT_STRING = "";
* @author Stuart // Properties
*/ @JsonProperty("id")
public class Company implements Serializable { private int companyId = 0;
@JsonProperty("name")
private static final long serialVersionUID = 1L; private String name = DEFAULT_STRING;
// Logger @JsonProperty("description")
private static final Logger LOG = LoggerFactory.getLogger(Company.class); private String description = DEFAULT_STRING;
private static final String DEFAULT_STRING = ""; @JsonProperty("headquarters")
// Properties private String headquarters = DEFAULT_STRING;
@JsonProperty("id") @JsonProperty("homepage")
private int companyId = 0; private String homepage = DEFAULT_STRING;
@JsonProperty("name") @JsonProperty("logo_path")
private String name = DEFAULT_STRING; private String logoPath = DEFAULT_STRING;
@JsonProperty("description") @JsonProperty("parent_company")
private String description = DEFAULT_STRING; private Company parentCompany = null;
@JsonProperty("headquarters")
private String headquarters = DEFAULT_STRING; //<editor-fold defaultstate="collapsed" desc="Getter Methods">
@JsonProperty("homepage") public int getCompanyId() {
private String homepage = DEFAULT_STRING; return companyId;
@JsonProperty("logo_path") }
private String logoPath = DEFAULT_STRING;
@JsonProperty("parent_company") public String getDescription() {
private String parentCompany = DEFAULT_STRING; return description;
}
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public int getCompanyId() { public String getHeadquarters() {
return companyId; return headquarters;
} }
public String getDescription() { public String getHomepage() {
return description; return homepage;
} }
public String getHeadquarters() { public String getLogoPath() {
return headquarters; return logoPath;
} }
public String getHomepage() { public String getName() {
return homepage; return name;
} }
public String getLogoPath() { public Company getParentCompany() {
return logoPath; return parentCompany;
} }
public String getName() { public void setCompanyId(int companyId) {
return name; this.companyId = companyId;
} }
public String getParentCompany() { public void setDescription(String description) {
return parentCompany; this.description = description;
} }
//</editor-fold>
public void setHeadquarters(String headquarters) {
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> this.headquarters = headquarters;
public void setCompanyId(int companyId) { }
this.companyId = companyId;
} public void setHomepage(String homepage) {
this.homepage = homepage;
public void setDescription(String description) { }
this.description = description;
} public void setLogoPath(String logoPath) {
this.logoPath = logoPath;
public void setHeadquarters(String headquarters) { }
this.headquarters = headquarters;
} public void setName(String name) {
this.name = name;
public void setHomepage(String homepage) { }
this.homepage = homepage;
} public void setParentCompany(Company parentCompany) {
this.parentCompany = parentCompany;
public void setLogoPath(String logoPath) { }
this.logoPath = logoPath;
} public void setParentCompany(int id, String name, String logoPath) {
Company parent = new Company();
public void setName(String name) { parent.setCompanyId(companyId);
this.name = name; parent.setName(name);
} parent.setLogoPath(logoPath);
this.parentCompany = parent;
public void setParentCompany(String parentCompany) { }
this.parentCompany = parentCompany; }
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -19,14 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.omertron.themoviedbapi.tools.ApiUrl.*; import static com.omertron.themoviedbapi.tools.ApiUrl.*;
import org.apache.commons.lang3.StringUtils;
/** /**
* Generate a discover object for use in the MovieDbApi * Generate a discover object for use in the MovieDbApi
* * <p/>
* This allows you to just add the search components you are concerned with * This allows you to just add the search components you are concerned with
* *
* @author stuart.boston * @author stuart.boston
@@ -49,7 +51,7 @@ public class Discover {
/** /**
* Get the parameters * Get the parameters
* * <p/>
* This will be used to construct the URL in the API * This will be used to construct the URL in the API
* *
* @return * @return
@@ -160,11 +162,11 @@ public class Discover {
/** /**
* Only include movies with the specified genres. * Only include movies with the specified genres.
* * <p/>
* Expected value is an integer (the id of a genre). * Expected value is an integer (the id of a genre).
* * <p/>
* Multiple values can be specified. * Multiple values can be specified.
* * <p/>
* Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR' * Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'
* *
* @param withGenres * @param withGenres
@@ -178,7 +180,7 @@ public class Discover {
/** /**
* The minimum release to include. * The minimum release to include.
* * <p/>
* Expected format is YYYY-MM-DD. * Expected format is YYYY-MM-DD.
* *
* @param releaseDateGte * @param releaseDateGte
@@ -192,7 +194,7 @@ public class Discover {
/** /**
* The maximum release to include. * The maximum release to include.
* * <p/>
* Expected format is YYYY-MM-DD. * Expected format is YYYY-MM-DD.
* *
* @param releaseDateLte * @param releaseDateLte
@@ -206,9 +208,9 @@ public class Discover {
/** /**
* Only include movies with certifications for a specific country. * Only include movies with certifications for a specific country.
* * <p/>
* When this value is specified, 'certificationLte' is required. * When this value is specified, 'certificationLte' is required.
* * <p/>
* A ISO 3166-1 is expected * A ISO 3166-1 is expected
* *
* @param certificationCountry * @param certificationCountry
@@ -222,7 +224,7 @@ public class Discover {
/** /**
* Only include movies with this certification and lower. * Only include movies with this certification and lower.
* * <p/>
* Expected value is a valid certification for the specified 'certificationCountry'. * Expected value is a valid certification for the specified 'certificationCountry'.
* *
* @param certificationLte * @param certificationLte
@@ -236,9 +238,9 @@ public class Discover {
/** /**
* Filter movies to include a specific company. * Filter movies to include a specific company.
* * <p/>
* Expected value is an integer (the id of a company). * Expected value is an integer (the id of a company).
* * <p/>
* They can be comma separated to indicate an 'AND' query * They can be comma separated to indicate an 'AND' query
* *
* @param withCompanies * @param withCompanies
@@ -1,115 +1,82 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author stuart.boston
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; @JsonRootName("genre")
import org.slf4j.LoggerFactory; public class Genre extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
* /*
* @author stuart.boston * Properties
*/ */
@JsonRootName("genre") @JsonProperty("id")
public class Genre implements Serializable { private int id;
@JsonProperty("name")
private static final long serialVersionUID = 1L; private String name;
/*
* Logger //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public int getId() {
private static final Logger LOG = LoggerFactory.getLogger(Genre.class); return id;
/* }
* Properties
*/ public String getName() {
@JsonProperty("id") return name;
private int id; }
@JsonProperty("name")
private String name; public void setId(int id) {
this.id = id;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public int getId() {
return id; public void setName(String name) {
} this.name = name;
}
public String getName() {
return name; @Override
} public boolean equals(Object obj) {
//</editor-fold> if (obj == null) {
return false;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setId(int id) { if (getClass() != obj.getClass()) {
this.id = id; return false;
} }
final Genre other = (Genre) obj;
public void setName(String name) { if (this.id != other.id) {
this.name = name; return false;
} }
//</editor-fold> if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
/** }
* Handle unknown properties and print a message return true;
* }
* @param key
* @param value @Override
*/ public int hashCode() {
@JsonAnySetter int hash = 5;
public void handleUnknown(String key, Object value) { hash = 53 * hash + this.id;
StringBuilder sb = new StringBuilder(); hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
sb.append("Unknown property: '").append(key); return hash;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); }
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Genre other = (Genre) obj;
if (this.id != other.id) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + this.id;
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -19,19 +19,13 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JobDepartment { public class JobDepartment {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Logger
private static final Logger LOG = LoggerFactory.getLogger(JobDepartment.class);
// Properties // Properties
@JsonProperty("department") @JsonProperty("department")
private String department; private String department;
@@ -46,7 +40,6 @@ public class JobDepartment {
public List<String> getJobs() { public List<String> getJobs() {
return jobs; return jobs;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setters"> //<editor-fold defaultstate="collapsed" desc="Setters">
public void setDepartment(String department) { public void setDepartment(String department) {
@@ -56,24 +49,4 @@ public class JobDepartment {
public void setJobs(List<String> jobs) { public void setJobs(List<String> jobs) {
this.jobs = jobs; this.jobs = jobs;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,116 +1,83 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author stuart.boston
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; @JsonRootName("keyword")
import org.slf4j.LoggerFactory; public class Keyword extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
*
* @author stuart.boston /*
*/ * Properties
@JsonRootName("keyword") */
public class Keyword implements Serializable { @JsonProperty("id")
private int id;
private static final long serialVersionUID = 1L; @JsonProperty("name")
private String name;
/*
* Logger //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public int getId() {
private static final Logger LOG = LoggerFactory.getLogger(Keyword.class); return id;
/* }
* Properties
*/ public String getName() {
@JsonProperty("id") return name;
private int id; }
@JsonProperty("name")
private String name; public void setId(int id) {
this.id = id;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public int getId() {
return id; public void setName(String name) {
} this.name = name;
}
public String getName() {
return name; @Override
} public boolean equals(Object obj) {
//</editor-fold> if (obj == null) {
return false;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setId(int id) { if (getClass() != obj.getClass()) {
this.id = id; return false;
} }
final Keyword other = (Keyword) obj;
public void setName(String name) { if (this.id != other.id) {
this.name = name; return false;
} }
//</editor-fold> if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
/** }
* Handle unknown properties and print a message return true;
* }
* @param key
* @param value @Override
*/ public int hashCode() {
@JsonAnySetter int hash = 3;
public void handleUnknown(String key, Object value) { hash = 83 * hash + this.id;
StringBuilder sb = new StringBuilder(); hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
sb.append("Unknown property: '").append(key); return hash;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); }
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Keyword other = (Keyword) obj;
if (this.id != other.id) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 83 * hash + this.id;
hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,172 +1,142 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author Stuart
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; public class KeywordMovie extends AbstractJsonMapping {
import org.slf4j.LoggerFactory;
private static final long serialVersionUID = 1L;
/**
* /*
* @author Stuart * Properties
*/ */
public class KeywordMovie implements Serializable { @JsonProperty("id")
private String id;
private static final long serialVersionUID = 1L; @JsonProperty("backdrop_path")
private String backdropPath;
/* @JsonProperty("original_title")
* Logger private String originalTitle;
*/ @JsonProperty("release_date")
private static final Logger LOG = LoggerFactory.getLogger(KeywordMovie.class); private String releaseDate;
/* @JsonProperty("poster_path")
* Properties private String posterPath;
*/ @JsonProperty("title")
@JsonProperty("id") private String title;
private String id; @JsonProperty("vote_average")
@JsonProperty("backdrop_path") private float voteAverage;
private String backdropPath; @JsonProperty("vote_count")
@JsonProperty("original_title") private double voteCount;
private String originalTitle; @JsonProperty("adult")
@JsonProperty("release_date") private boolean adult;
private String releaseDate; @JsonProperty("popularity")
@JsonProperty("poster_path") private float popularity;
private String posterPath;
@JsonProperty("title") // <editor-fold defaultstate="collapsed" desc="Getter methods">
private String title; public static long getSerialVersionUID() {
@JsonProperty("vote_average") return serialVersionUID;
private float voteAverage; }
@JsonProperty("vote_count")
private double voteCount; public String getBackdropPath() {
@JsonProperty("adult") return backdropPath;
private boolean adult; }
@JsonProperty("popularity")
private float popularity; public String getId() {
return id;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> }
public static long getSerialVersionUID() {
return serialVersionUID; public String getOriginalTitle() {
} return originalTitle;
}
public String getBackdropPath() {
return backdropPath; public String getReleaseDate() {
} return releaseDate;
}
public String getId() {
return id; public String getPosterPath() {
} return posterPath;
}
public String getOriginalTitle() {
return originalTitle; public String getTitle() {
} return title;
}
public String getReleaseDate() {
return releaseDate; public float getVoteAverage() {
} return voteAverage;
}
public String getPosterPath() {
return posterPath; public double getVoteCount() {
} return voteCount;
}
public String getTitle() {
return title; public boolean isAdult() {
} return adult;
}
public float getVoteAverage() {
return voteAverage; public float getPopularity() {
} return popularity;
}
public double getVoteCount() { // </editor-fold>
return voteCount;
} // <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) {
public boolean isAdult() { this.backdropPath = backdropPath;
return adult; }
}
public void setId(String id) {
public float getPopularity() { this.id = id;
return popularity; }
}
// </editor-fold> public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; public void setReleaseDate(String releaseDate) {
} this.releaseDate = releaseDate;
}
public void setId(String id) {
this.id = id; public void setPosterPath(String posterPath) {
} this.posterPath = posterPath;
}
public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle; public void setTitle(String title) {
} this.title = title;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; public void setVoteAverage(float voteAverage) {
} this.voteAverage = voteAverage;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath; public void setVoteCount(double voteCount) {
} this.voteCount = voteCount;
}
public void setTitle(String title) {
this.title = title; public void setAdult(boolean adult) {
} this.adult = adult;
}
public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage; public void setPopularity(float popularity) {
} this.popularity = popularity;
}
public void setVoteCount(double voteCount) { // </editor-fold>
this.voteCount = voteCount; }
}
public void setAdult(boolean adult) {
this.adult = adult;
}
public void setPopularity(float popularity) {
this.popularity = popularity;
}
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,115 +1,82 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author stuart.boston
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; @JsonRootName("spoken_language")
import org.slf4j.LoggerFactory; public class Language extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
* /*
* @author stuart.boston * Properties
*/ */
@JsonRootName("spoken_language") @JsonProperty("iso_639_1")
public class Language implements Serializable { private String isoCode;
@JsonProperty("name")
private static final long serialVersionUID = 1L; private String name;
/*
* Logger //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public String getIsoCode() {
private static final Logger LOG = LoggerFactory.getLogger(Language.class); return isoCode;
/* }
* Properties
*/ public String getName() {
@JsonProperty("iso_639_1") return name;
private String isoCode; }
@JsonProperty("name")
private String name; public void setIsoCode(String isoCode) {
this.isoCode = isoCode;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getIsoCode() {
return isoCode; public void setName(String name) {
} this.name = name;
}
public String getName() {
return name; @Override
} public boolean equals(Object obj) {
//</editor-fold> if (obj == null) {
return false;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setIsoCode(String isoCode) { if (getClass() != obj.getClass()) {
this.isoCode = isoCode; return false;
} }
final Language other = (Language) obj;
public void setName(String name) { if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
this.name = name; return false;
} }
//</editor-fold> if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
/** }
* Handle unknown properties and print a message return true;
* }
* @param key
* @param value @Override
*/ public int hashCode() {
@JsonAnySetter int hash = 7;
public void handleUnknown(String key, Object value) { hash = 71 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
StringBuilder sb = new StringBuilder(); hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
sb.append("Unknown property: '").append(key); return hash;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); }
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Language other = (Language) obj;
if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 71 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2004-2013 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.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Holger Brandl
*/
public class ListItemStatus extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("status_code")
private int statusCode;
@JsonProperty("item_present")
private boolean itemPresent;
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public boolean isItemPresent() {
return itemPresent;
}
public void setItemPresent(boolean itemPresent) {
this.itemPresent = itemPresent;
}
}
@@ -19,37 +19,19 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; import com.omertron.themoviedbapi.wrapper.*;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts;
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
import com.omertron.themoviedbapi.wrapper.WrapperMovieList;
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
import com.omertron.themoviedbapi.wrapper.WrapperReviews;
import com.omertron.themoviedbapi.wrapper.WrapperTrailers;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Movie Bean * Movie Bean
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class MovieDb implements Serializable { public class MovieDb extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class);
/* /*
* Properties * Properties
*/ */
@@ -93,6 +75,8 @@ public class MovieDb implements Serializable {
private List<Language> spokenLanguages; private List<Language> spokenLanguages;
@JsonProperty("tagline") @JsonProperty("tagline")
private String tagline; private String tagline;
@JsonProperty("rating")
private float userRating;
@JsonProperty("vote_average") @JsonProperty("vote_average")
private float voteAverage; private float voteAverage;
@JsonProperty("vote_count") @JsonProperty("vote_count")
@@ -213,6 +197,10 @@ public class MovieDb implements Serializable {
public String getStatus() { public String getStatus() {
return status; return status;
} }
public float getUserRating() {
return userRating;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -308,6 +296,9 @@ public class MovieDb implements Serializable {
this.status = status; this.status = status;
} }
public void setUserRating(float userRating) {
this.userRating = userRating;
}
// </editor-fold> // </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters"> //<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
@@ -354,7 +345,7 @@ public class MovieDb implements Serializable {
public List<Reviews> getReviews() { public List<Reviews> getReviews() {
return reviews.getReviews(); return reviews.getReviews();
} }
//</editor-fold> // </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters"> //<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) { public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
@@ -396,22 +387,7 @@ public class MovieDb implements Serializable {
public void setReviews(WrapperReviews reviews) { public void setReviews(WrapperReviews reviews) {
this.reviews = reviews; this.reviews = reviews;
} }
// </editor-fold>
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode"> //<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
@Override @Override
@@ -443,10 +419,5 @@ public class MovieDb implements Serializable {
hash = 89 * hash + this.runtime; hash = 89 * hash + this.runtime;
return hash; return hash;
} }
//</editor-fold> // </editor-fold>
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,158 +1,151 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; /**
import org.slf4j.Logger; * Wrapper for the MovieDbList function
import org.slf4j.LoggerFactory; *
* @author stuart.boston
/** */
* Wrapper for the MovieDbList function public class MovieDbList extends AbstractJsonMapping {
*
* @author stuart.boston /*
*/ * Properties
public class MovieDbList { */
/* @JsonProperty("id")
* Logger private String id;
*/ @JsonProperty("created_by")
private String createdBy;
private static final Logger LOG = LoggerFactory.getLogger(MovieDbList.class); @JsonProperty("description")
/* private String description;
* Properties @JsonProperty("favorite_count")
*/ private int favoriteCount;
@JsonProperty("id") @JsonProperty("items")
private String id; private List<MovieDb> items = Collections.EMPTY_LIST;
@JsonProperty("created_by") @JsonProperty("item_count")
private String createdBy; private int itemCount;
@JsonProperty("description") @JsonProperty("iso_639_1")
private String description; private String language;
@JsonProperty("favorite_count") @JsonProperty("name")
private int favoriteCount; private String name;
@JsonProperty("items") @JsonProperty("poster_path")
private List<MovieDb> items = Collections.EMPTY_LIST; private String posterPath;
@JsonProperty("item_count") @JsonProperty("status_code")
private int itemCount; private String statusCode;
@JsonProperty("iso_639_1") @JsonProperty("status_message")
private String language; private String statusMessage;
@JsonProperty("name")
private String name; //<editor-fold defaultstate="collapsed" desc="Getter Methods">
@JsonProperty("poster_path") public String getId() {
private String posterPath; return id;
}
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() { public String getCreatedBy() {
return id; return createdBy;
} }
public String getCreatedBy() { public String getDescription() {
return createdBy; return description;
} }
public String getDescription() { public int getFavoriteCount() {
return description; return favoriteCount;
} }
public int getFavoriteCount() { public List<MovieDb> getItems() {
return favoriteCount; return items;
} }
public List<MovieDb> getItems() { public int getItemCount() {
return items; return itemCount;
} }
public int getItemCount() { public String getLanguage() {
return itemCount; return language;
} }
public String getLanguage() { public String getName() {
return language; return name;
} }
public String getName() { public String getPosterPath() {
return name; return posterPath;
} }
public String getPosterPath() { public String getStatusCode() {
return posterPath; return statusCode;
} }
//</editor-fold>
public String getStatusMessage() {
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> return statusMessage;
public void setId(String id) { }
this.id = id; //</editor-fold>
}
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setCreatedBy(String createdBy) { public void setId(String id) {
this.createdBy = createdBy; this.id = id;
} }
public void setDescription(String description) { public void setCreatedBy(String createdBy) {
this.description = description; this.createdBy = createdBy;
} }
public void setFavoriteCount(int favoriteCount) { public void setDescription(String description) {
this.favoriteCount = favoriteCount; this.description = description;
} }
public void setItems(List<MovieDb> items) { public void setFavoriteCount(int favoriteCount) {
this.items = items; this.favoriteCount = favoriteCount;
} }
public void setItemCount(int itemCount) { public void setItems(List<MovieDb> items) {
this.itemCount = itemCount; this.items = items;
} }
public void setLanguage(String language) { public void setItemCount(int itemCount) {
this.language = language; this.itemCount = itemCount;
} }
public void setName(String name) { public void setLanguage(String language) {
this.name = name; this.language = language;
} }
public void setPosterPath(String posterPath) { public void setName(String name) {
this.posterPath = posterPath; this.name = name;
} }
//</editor-fold>
public void setPosterPath(String posterPath) {
/** this.posterPath = posterPath;
* Handle unknown properties and print a message }
*
* @param key public void setStatusCode(String statusCode) {
* @param value this.statusCode = statusCode;
*/ }
@JsonAnySetter
public void handleUnknown(String key, Object value) { public void setStatusMessage(String statusMessage) {
StringBuilder sb = new StringBuilder(); this.statusMessage = statusMessage;
sb.append("Unknown property: '").append(key); }
sb.append("' value: '").append(value).append("'"); //</editor-fold>
LOG.trace(sb.toString()); }
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2004-2013 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;
import com.fasterxml.jackson.annotation.JsonProperty;
public class MovieDbListStatus extends StatusCode {
@JsonProperty("list_id")
private String listId;
public String getListId() {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
}
@@ -1,148 +1,118 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author Stuart
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; public class MovieList extends AbstractJsonMapping {
import org.slf4j.LoggerFactory;
private static final long serialVersionUID = 1L;
/**
* /*
* @author Stuart * Properties
*/ */
public class MovieList implements Serializable { @JsonProperty("description")
private String description;
private static final long serialVersionUID = 1L; @JsonProperty("favorite_count")
private int favoriteCount;
/* @JsonProperty("id")
* Logger private String id;
*/ @JsonProperty("item_count")
private static final Logger LOG = LoggerFactory.getLogger(MovieList.class); private int itemCount;
/* @JsonProperty("iso_639_1")
* Properties private String language;
*/ @JsonProperty("name")
@JsonProperty("description") private String name;
private String description; @JsonProperty("poster_path")
@JsonProperty("favorite_count") private String posterPath;
private int favoriteCount; @JsonProperty("list_type")
@JsonProperty("id") private String listType;
private String id;
@JsonProperty("item_count") // <editor-fold defaultstate="collapsed" desc="Getter methods">
private int itemCount; public String getDescription() {
@JsonProperty("iso_639_1") return description;
private String language; }
@JsonProperty("name")
private String name; public int getFavoriteCount() {
@JsonProperty("poster_path") return favoriteCount;
private String posterPath; }
@JsonProperty("list_type")
private String listType; public String getId() {
return id;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getDescription() {
return description; public int getItemCount() {
} return itemCount;
}
public int getFavoriteCount() {
return favoriteCount; public String getLanguage() {
} return language;
}
public String getId() {
return id; public String getName() {
} return name;
}
public int getItemCount() {
return itemCount; public String getPosterPath() {
} return posterPath;
}
public String getLanguage() {
return language; public String getListType() {
} return listType;
}
public String getName() { // </editor-fold>
return name;
} // <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDescription(String description) {
public String getPosterPath() { this.description = description;
return posterPath; }
}
public void setFavoriteCount(int favoriteCount) {
public String getListType() { this.favoriteCount = favoriteCount;
return listType; }
}
// </editor-fold> public void setId(String id) {
this.id = id;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setDescription(String description) {
this.description = description; public void setItemCount(int itemCount) {
} this.itemCount = itemCount;
}
public void setFavoriteCount(int favoriteCount) {
this.favoriteCount = favoriteCount; public void setLanguage(String language) {
} this.language = language;
}
public void setId(String id) {
this.id = id; public void setName(String name) {
} this.name = name;
}
public void setItemCount(int itemCount) {
this.itemCount = itemCount; public void setPosterPath(String posterPath) {
} this.posterPath = posterPath;
}
public void setLanguage(String language) {
this.language = language; public void setListType(String listType) {
} this.listType = listType;
}
public void setName(String name) { // </editor-fold>
this.name = name; }
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setListType(String listType) {
this.listType = listType;
}
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,328 +1,299 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; /**
import org.slf4j.Logger; * @author stuart.boston
import org.slf4j.LoggerFactory; */
public class Person extends AbstractJsonMapping {
/**
* private static final long serialVersionUID = 1L;
* @author stuart.boston
*/ /*
public class Person implements Serializable { * Static fields for default cast information
*/
private static final long serialVersionUID = 1L; private static final String CAST_DEPARTMENT = "acting";
private static final String CAST_JOB = "actor";
/* private static final String DEFAULT_STRING = "";
* Logger /*
*/ * Properties
private static final Logger LOG = LoggerFactory.getLogger(Person.class); */
@JsonProperty("id")
/* private int id = -1;
* Static fields for default cast information @JsonProperty("name")
*/ private String name = "";
private static final String CAST_DEPARTMENT = "acting"; @JsonProperty("profile_path")
private static final String CAST_JOB = "actor"; private String profilePath = DEFAULT_STRING;
private static final String DEFAULT_STRING = ""; private PersonType personType = PersonType.PERSON;
/* private String department = DEFAULT_STRING; // Crew
* Properties private String job = DEFAULT_STRING; // Crew
*/ private String character = DEFAULT_STRING; // Cast
@JsonProperty("id") private int order = -1; // Cast
private int id = -1; @JsonProperty("adult")
@JsonProperty("name") private boolean adult = false; // Person info
private String name = ""; @JsonProperty("also_known_as")
@JsonProperty("profile_path") private List<String> aka = new ArrayList<String>();
private String profilePath = DEFAULT_STRING; @JsonProperty("biography")
private PersonType personType = PersonType.PERSON; private String biography = DEFAULT_STRING;
private String department = DEFAULT_STRING; // Crew @JsonProperty("birthday")
private String job = DEFAULT_STRING; // Crew private String birthday = DEFAULT_STRING;
private String character = DEFAULT_STRING; // Cast @JsonProperty("deathday")
private int order = -1; // Cast private String deathday = DEFAULT_STRING;
@JsonProperty("adult") @JsonProperty("homepage")
private boolean adult = false; // Person info private String homepage = DEFAULT_STRING;
@JsonProperty("also_known_as") @JsonProperty("place_of_birth")
private List<String> aka = new ArrayList<String>(); private String birthplace = DEFAULT_STRING;
@JsonProperty("biography") @JsonProperty("imdb_id")
private String biography = DEFAULT_STRING; private String imdbId = DEFAULT_STRING;
@JsonProperty("birthday") @JsonProperty("popularity")
private String birthday = DEFAULT_STRING; private float popularity = 0.0f;
@JsonProperty("deathday")
private String deathday = DEFAULT_STRING; /**
@JsonProperty("homepage") * Add a crew member
private String homepage = DEFAULT_STRING; *
@JsonProperty("place_of_birth") * @param id
private String birthplace = DEFAULT_STRING; * @param name
@JsonProperty("imdb_id") * @param profilePath
private String imdbId = DEFAULT_STRING; * @param department
@JsonProperty("popularity") * @param job
private float popularity = 0.0f; */
public void addCrew(int id, String name, String profilePath, String department, String job) {
/** setPersonType(PersonType.CREW);
* Add a crew member setId(id);
* setName(name);
* @param id setProfilePath(profilePath);
* @param name setDepartment(department);
* @param profilePath setJob(job);
* @param department setCharacter("");
* @param job setOrder(-1);
*/ }
public void addCrew(int id, String name, String profilePath, String department, String job) {
this.personType = PersonType.CREW; /**
this.id = id; * Add a cast member
this.name = name; *
this.profilePath = profilePath; * @param id
this.department = department; * @param name
this.job = job; * @param profilePath
this.character = ""; * @param character
this.order = -1; * @param order
} */
public void addCast(int id, String name, String profilePath, String character, int order) {
/** setPersonType(PersonType.CAST);
* Add a cast member setId(id);
* setName(name);
* @param id setProfilePath(profilePath);
* @param name setCharacter(character);
* @param profilePath setOrder(order);
* @param character setDepartment(CAST_DEPARTMENT);
* @param order setJob(CAST_JOB);
*/ }
public void addCast(int id, String name, String profilePath, String character, int order) {
this.personType = PersonType.CAST; // <editor-fold defaultstate="collapsed" desc="Getter methods">
this.id = id; public String getCharacter() {
this.name = name; return character;
this.profilePath = profilePath; }
this.character = character;
this.order = order; public String getDepartment() {
this.department = CAST_DEPARTMENT; return department;
this.job = CAST_JOB; }
}
public int getId() {
// <editor-fold defaultstate="collapsed" desc="Getter methods"> return id;
public String getCharacter() { }
return character;
} public String getJob() {
return job;
public String getDepartment() { }
return department;
} public String getName() {
return name;
public int getId() { }
return id;
} public int getOrder() {
return order;
public String getJob() { }
return job;
} public PersonType getPersonType() {
return personType;
public String getName() { }
return name;
} public String getProfilePath() {
return profilePath;
public int getOrder() { }
return order;
} public boolean isAdult() {
return adult;
public PersonType getPersonType() { }
return personType;
} public List<String> getAka() {
return aka;
public String getProfilePath() { }
return profilePath;
} public String getBiography() {
return biography;
public boolean isAdult() { }
return adult;
} public String getBirthday() {
return birthday;
public List<String> getAka() { }
return aka;
} public String getBirthplace() {
return birthplace;
public String getBiography() { }
return biography;
} public String getDeathday() {
return deathday;
public String getBirthday() { }
return birthday;
} public String getHomepage() {
return homepage;
public String getBirthplace() { }
return birthplace;
} public String getImdbId() {
return imdbId;
public String getDeathday() { }
return deathday;
} public float getPopularity() {
return popularity;
public String getHomepage() { }
return homepage; // </editor-fold>
}
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public String getImdbId() { public void setCharacter(String character) {
return imdbId; this.character = character;
} }
public float getPopularity() { public void setDepartment(String department) {
return popularity; this.department = department;
} }
// </editor-fold>
public void setId(int id) {
// <editor-fold defaultstate="collapsed" desc="Setter methods"> this.id = id;
public void setCharacter(String character) { }
this.character = character;
} public void setJob(String job) {
this.job = StringUtils.trimToEmpty(job);
public void setDepartment(String department) { }
this.department = department;
} public void setName(String name) {
this.name = StringUtils.trimToEmpty(name);
public void setId(int id) { }
this.id = id;
} public void setOrder(int order) {
this.order = order;
public void setJob(String job) { }
this.job = job;
} public void setPersonType(PersonType personType) {
this.personType = personType;
public void setName(String name) { }
this.name = name;
} public void setProfilePath(String profilePath) {
this.profilePath = StringUtils.trimToEmpty(profilePath);
public void setOrder(int order) { }
this.order = order;
} public void setAdult(boolean adult) {
this.adult = adult;
public void setPersonType(PersonType personType) { }
this.personType = personType;
} public void setAka(List<String> aka) {
this.aka = aka;
public void setProfilePath(String profilePath) { }
this.profilePath = profilePath;
} public void setBiography(String biography) {
this.biography = StringUtils.trimToEmpty(biography);
public void setAdult(boolean adult) { }
this.adult = adult;
} public void setBirthday(String birthday) {
this.birthday = StringUtils.trimToEmpty(birthday);
public void setAka(List<String> aka) { }
this.aka = aka;
} public void setBirthplace(String birthplace) {
this.birthplace = StringUtils.trimToEmpty(birthplace);
public void setBiography(String biography) { }
this.biography = biography;
} public void setDeathday(String deathday) {
this.deathday = StringUtils.trimToEmpty(deathday);
public void setBirthday(String birthday) { }
this.birthday = birthday;
} public void setHomepage(String homepage) {
this.homepage = StringUtils.trimToEmpty(homepage);
public void setBirthplace(String birthplace) { }
this.birthplace = birthplace;
} public void setImdbId(String imdbId) {
this.imdbId = StringUtils.trimToEmpty(imdbId);
public void setDeathday(String deathday) { }
this.deathday = deathday;
} public void setPopularity(float popularity) {
this.popularity = popularity;
public void setHomepage(String homepage) { }
this.homepage = homepage; // </editor-fold>
}
@Override
public void setImdbId(String imdbId) { public boolean equals(Object obj) {
this.imdbId = imdbId; if (obj == null) {
} return false;
}
public void setPopularity(float popularity) { if (getClass() != obj.getClass()) {
this.popularity = popularity; return false;
} }
// </editor-fold> final Person other = (Person) obj;
if (this.id != other.id) {
/** return false;
* Handle unknown properties and print a message }
* if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
* @param key return false;
* @param value }
*/ if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) {
@JsonAnySetter return false;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); if (this.personType != other.personType) {
sb.append("Unknown property: '").append(key); return false;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
} return false;
}
@Override if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
public boolean equals(Object obj) { return false;
if (obj == null) { }
return false; if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) {
} return false;
if (getClass() != obj.getClass()) { }
return false; return true;
} }
final Person other = (Person) obj;
if (this.id != other.id) { @Override
return false; public int hashCode() {
} int hash = 3;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { hash = 37 * hash + this.id;
return false; hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 37 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { hash = 37 * hash + (this.personType != null ? this.personType.hashCode() : 0);
return false; hash = 37 * hash + (this.department != null ? this.department.hashCode() : 0);
} hash = 37 * hash + (this.job != null ? this.job.hashCode() : 0);
if (this.personType != other.personType) { hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
return false; return hash;
} }
if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { }
return false;
}
if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
return false;
}
if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 37 * hash + this.id;
hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 37 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
hash = 37 * hash + (this.personType != null ? this.personType.hashCode() : 0);
hash = 37 * hash + (this.department != null ? this.department.hashCode() : 0);
hash = 37 * hash + (this.job != null ? this.job.hashCode() : 0);
hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,168 +1,134 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder; /**
import org.apache.commons.lang3.builder.ToStringStyle; * @author Stuart
import org.slf4j.Logger; */
import org.slf4j.LoggerFactory; public class PersonCast extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
*
* @author Stuart /*
*/ * Properties
public class PersonCast implements Serializable { */
@JsonProperty("id")
private static final long serialVersionUID = 1L; private int id;
@JsonProperty("character")
/* private String character;
* Logger @JsonProperty("name")
*/ private String name;
private static final Logger LOG = LoggerFactory.getLogger(PersonCast.class); @JsonProperty("order")
/* private int order;
* Properties @JsonProperty("profile_path")
*/ private String profilePath;
@JsonProperty("id") @JsonProperty("cast_id")
private int id; private int castId;
@JsonProperty("character")
private String character; //<editor-fold defaultstate="collapsed" desc="Getter methods">
@JsonProperty("name") public String getCharacter() {
private String name; return character;
@JsonProperty("order") }
private int order;
@JsonProperty("profile_path") public int getId() {
private String profilePath; return id;
@JsonProperty("cast_id") }
private int castId;
public String getName() {
//<editor-fold defaultstate="collapsed" desc="Getter methods"> return name;
public String getCharacter() { }
return character;
} public int getOrder() {
return order;
public int getId() { }
return id;
} public String getProfilePath() {
return profilePath;
public String getName() { }
return name;
} public int getCastId() {
return castId;
public int getOrder() { }
return order;
} public void setCharacter(String character) {
this.character = StringUtils.trimToEmpty(character);
public String getProfilePath() { }
return profilePath;
} public void setId(int id) {
this.id = id;
public int getCastId() { }
return castId;
} public void setName(String name) {
this.name = StringUtils.trimToEmpty(name);
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public void setOrder(int order) {
public void setCharacter(String character) { this.order = order;
this.character = character; }
}
public void setProfilePath(String profilePath) {
public void setId(int id) { this.profilePath = StringUtils.trimToEmpty(profilePath);
this.id = id; }
}
public void setCastId(int castId) {
public void setName(String name) { this.castId = castId;
this.name = name; }
}
@Override
public void setOrder(int order) { public boolean equals(Object obj) {
this.order = order; if (obj == null) {
} return false;
}
public void setProfilePath(String profilePath) { if (getClass() != obj.getClass()) {
this.profilePath = profilePath; return false;
} }
final PersonCast other = (PersonCast) obj;
public void setCastId(int castId) { if (this.id != other.id) {
this.castId = castId; return false;
} }
if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) {
//</editor-fold> return false;
}
/** if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
* Handle unknown properties and print a message return false;
* }
* @param key if (this.order != other.order) {
* @param value return false;
*/ }
@JsonAnySetter if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) {
public void handleUnknown(String key, Object value) { return false;
StringBuilder sb = new StringBuilder(); }
sb.append("Unknown property: '").append(key); return true;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString());
} @Override
public int hashCode() {
@Override int hash = 7;
public boolean equals(Object obj) { hash = 41 * hash + this.id;
if (obj == null) { hash = 41 * hash + (this.character != null ? this.character.hashCode() : 0);
return false; hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 41 * hash + this.order;
if (getClass() != obj.getClass()) { hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return false; return hash;
} }
final PersonCast other = (PersonCast) obj; }
if (this.id != other.id) {
return false;
}
if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if (this.order != other.order) {
return false;
}
if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 41 * hash + this.id;
hash = 41 * hash + (this.character != null ? this.character.hashCode() : 0);
hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 41 * hash + this.order;
hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,168 +1,135 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder; /**
import org.apache.commons.lang3.builder.ToStringStyle; * @author stuart.boston
import org.slf4j.Logger; */
import org.slf4j.LoggerFactory; public class PersonCredit extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
* private static final String DEFAULT_STRING = "";
* @author stuart.boston /*
*/ * Properties
public class PersonCredit implements Serializable { */
@JsonProperty("id")
private static final long serialVersionUID = 1L; private int movieId = 0;
@JsonProperty("character")
/* private String character = DEFAULT_STRING;
* Logger @JsonProperty("original_title")
*/ private String movieOriginalTitle = DEFAULT_STRING;
private static final Logger LOG = LoggerFactory.getLogger(PersonCredit.class); @JsonProperty("poster_path")
private static final String DEFAULT_STRING = ""; private String posterPath = DEFAULT_STRING;
/* @JsonProperty("release_date")
* Properties private String releaseDate = DEFAULT_STRING;
*/ @JsonProperty("title")
@JsonProperty("id") private String movieTitle = DEFAULT_STRING;
private int movieId = 0; @JsonProperty("department")
@JsonProperty("character") private String department = DEFAULT_STRING;
private String character = DEFAULT_STRING; @JsonProperty("job")
@JsonProperty("original_title") private String job = DEFAULT_STRING;
private String movieOriginalTitle = DEFAULT_STRING; @JsonProperty("adult")
@JsonProperty("poster_path") private String adult = DEFAULT_STRING;
private String posterPath = DEFAULT_STRING; private PersonType personType = PersonType.PERSON;
@JsonProperty("release_date")
private String releaseDate = DEFAULT_STRING; //<editor-fold defaultstate="collapsed" desc="Getter Methods">
@JsonProperty("title") public String getCharacter() {
private String movieTitle = DEFAULT_STRING; return character;
@JsonProperty("department") }
private String department = DEFAULT_STRING;
@JsonProperty("job") public String getDepartment() {
private String job = DEFAULT_STRING; return department;
@JsonProperty("adult") }
private String adult = DEFAULT_STRING;
private PersonType personType = PersonType.PERSON; public String getJob() {
return job;
//<editor-fold defaultstate="collapsed" desc="Getter Methods"> }
public String getCharacter() {
return character; public int getMovieId() {
} return movieId;
}
public String getDepartment() {
return department; public String getMovieOriginalTitle() {
} return movieOriginalTitle;
}
public String getJob() {
return job; public String getMovieTitle() {
} return movieTitle;
}
public int getMovieId() {
return movieId; public PersonType getPersonType() {
} return personType;
}
public String getMovieOriginalTitle() {
return movieOriginalTitle; public String getPosterPath() {
} return posterPath;
}
public String getMovieTitle() {
return movieTitle; public String getReleaseDate() {
} return releaseDate;
}
public PersonType getPersonType() {
return personType; public String getAdult() {
} return adult;
}
public String getPosterPath() {
return posterPath; public void setCharacter(String character) {
} this.character = StringUtils.trimToEmpty(character);
}
public String getReleaseDate() {
return releaseDate; public void setDepartment(String department) {
} this.department = StringUtils.trimToEmpty(department);
}
public String getAdult() {
return adult; public void setJob(String job) {
} this.job = StringUtils.trimToEmpty(job);
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> public void setMovieId(int movieId) {
public void setCharacter(String character) { this.movieId = movieId;
this.character = character; }
}
public void setMovieOriginalTitle(String movieOriginalTitle) {
public void setDepartment(String department) { this.movieOriginalTitle = StringUtils.trimToEmpty(movieOriginalTitle);
this.department = department; }
}
public void setMovieTitle(String movieTitle) {
public void setJob(String job) { this.movieTitle = StringUtils.trimToEmpty(movieTitle);
this.job = job; }
}
public void setPersonType(PersonType personType) {
public void setMovieId(int movieId) { this.personType = personType;
this.movieId = movieId; }
}
public void setPosterPath(String posterPath) {
public void setMovieOriginalTitle(String movieOriginalTitle) { this.posterPath = StringUtils.trimToEmpty(posterPath);
this.movieOriginalTitle = movieOriginalTitle; }
}
public void setReleaseDate(String releaseDate) {
public void setMovieTitle(String movieTitle) { this.releaseDate = StringUtils.trimToEmpty(releaseDate);
this.movieTitle = movieTitle; }
}
public void setAdult(String adult) {
public void setPersonType(PersonType personType) { this.adult = StringUtils.trimToEmpty(adult);
this.personType = personType; }
} }
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public void setAdult(String adult) {
this.adult = adult;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,153 +1,121 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder; /**
import org.apache.commons.lang3.builder.ToStringStyle; * @author Stuart
import org.slf4j.Logger; */
import org.slf4j.LoggerFactory; public class PersonCrew extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
*
* @author Stuart /*
*/ * Properties
public class PersonCrew implements Serializable { */
@JsonProperty("id")
private static final long serialVersionUID = 1L; private int id;
@JsonProperty("department")
/* private String department;
* Logger @JsonProperty("job")
*/ private String job;
private static final Logger LOG = LoggerFactory.getLogger(PersonCrew.class); @JsonProperty("name")
/* private String name;
* Properties @JsonProperty("profile_path")
*/ private String profilePath;
@JsonProperty("id")
private int id; //<editor-fold defaultstate="collapsed" desc="Getter methods">
@JsonProperty("department") public String getDepartment() {
private String department; return department;
@JsonProperty("job") }
private String job;
@JsonProperty("name") public int getId() {
private String name; return id;
@JsonProperty("profile_path") }
private String profilePath;
public String getJob() {
//<editor-fold defaultstate="collapsed" desc="Getter methods"> return job;
public String getDepartment() { }
return department;
} public String getName() {
return name;
public int getId() { }
return id;
} public String getProfilePath() {
return profilePath;
public String getJob() { }
return job;
} public void setDepartment(String department) {
this.department = StringUtils.trimToEmpty(department);
public String getName() { }
return name;
} public void setId(int id) {
this.id = id;
public String getProfilePath() { }
return profilePath;
} public void setJob(String job) {
//</editor-fold> this.job = StringUtils.trimToEmpty(job);
}
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDepartment(String department) { public void setName(String name) {
this.department = department; this.name = StringUtils.trimToEmpty(name);
} }
public void setId(int id) { public void setProfilePath(String profilePath) {
this.id = id; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setJob(String job) { @Override
this.job = job; public boolean equals(Object obj) {
} if (obj == null) {
return false;
public void setName(String name) { }
this.name = name; if (getClass() != obj.getClass()) {
} return false;
}
public void setProfilePath(String profilePath) { final PersonCrew other = (PersonCrew) obj;
this.profilePath = profilePath; if (this.id != other.id) {
} return false;
//</editor-fold> }
if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
/** return false;
* Handle unknown properties and print a message }
* if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
* @param key return false;
* @param value }
*/ if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
@JsonAnySetter return false;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); return true;
sb.append("Unknown property: '").append(key); }
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString()); @Override
} public int hashCode() {
int hash = 7;
@Override hash = 59 * hash + this.id;
public boolean equals(Object obj) { hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
if (obj == null) { hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
return false; hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
if (getClass() != obj.getClass()) { return hash;
return false; }
} }
final PersonCrew other = (PersonCrew) obj;
if (this.id != other.id) {
return false;
}
if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
return false;
}
if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + this.id;
hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -20,12 +20,11 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public enum PersonType { public enum PersonType {
CAST, // A member of the cast CAST, // A member of the cast
CREW, // A member of the crew CREW, // A member of the crew
PERSON // No specific type PERSON // No specific type
} }
@@ -1,116 +1,83 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author stuart.boston
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; @JsonRootName("production_company")
import org.slf4j.LoggerFactory; public class ProductionCompany extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
*
* @author stuart.boston /*
*/ * Properties
@JsonRootName("production_company") */
public class ProductionCompany implements Serializable { @JsonProperty("id")
private int id;
private static final long serialVersionUID = 1L; @JsonProperty("name")
private String name;
/*
* Logger //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public int getId() {
private static final Logger LOG = LoggerFactory.getLogger(ProductionCompany.class); return id;
/* }
* Properties
*/ public String getName() {
@JsonProperty("id") return name;
private int id; }
@JsonProperty("name")
private String name; public void setId(int id) {
this.id = id;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public int getId() {
return id; public void setName(String name) {
} this.name = name;
}
public String getName() {
return name; @Override
} public boolean equals(Object obj) {
//</editor-fold> if (obj == null) {
return false;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setId(int id) { if (getClass() != obj.getClass()) {
this.id = id; return false;
} }
final ProductionCompany other = (ProductionCompany) obj;
public void setName(String name) { if (this.id != other.id) {
this.name = name; return false;
} }
//</editor-fold> if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
/** }
* Handle unknown properties and print a message return true;
* }
* @param key
* @param value @Override
*/ public int hashCode() {
@JsonAnySetter int hash = 5;
public void handleUnknown(String key, Object value) { hash = 37 * hash + this.id;
StringBuilder sb = new StringBuilder(); hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
sb.append("Unknown property: '").append(key); return hash;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); }
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ProductionCompany other = (ProductionCompany) obj;
if (this.id != other.id) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 37 * hash + this.id;
hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,116 +1,83 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author stuart.boston
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; @JsonRootName("production_country")
import org.slf4j.LoggerFactory; public class ProductionCountry extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
*
* @author stuart.boston /*
*/ * Properties
@JsonRootName("production_country") */
public class ProductionCountry implements Serializable { @JsonProperty("iso_3166_1")
private String isoCode;
private static final long serialVersionUID = 1L; @JsonProperty("name")
private String name;
/*
* Logger //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public String getIsoCode() {
private static final Logger LOG = LoggerFactory.getLogger(ProductionCountry.class); return isoCode;
/* }
* Properties
*/ public String getName() {
@JsonProperty("iso_3166_1") return name;
private String isoCode; }
@JsonProperty("name")
private String name; public void setIsoCode(String isoCode) {
this.isoCode = isoCode;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getIsoCode() {
return isoCode; public void setName(String name) {
} this.name = name;
}
public String getName() {
return name; @Override
} public boolean equals(Object obj) {
//</editor-fold> if (obj == null) {
return false;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setIsoCode(String isoCode) { if (getClass() != obj.getClass()) {
this.isoCode = isoCode; return false;
} }
final ProductionCountry other = (ProductionCountry) obj;
public void setName(String name) { if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
this.name = name; return false;
} }
//</editor-fold> if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
/** }
* Handle unknown properties and print a message return true;
* }
* @param key
* @param value @Override
*/ public int hashCode() {
@JsonAnySetter int hash = 7;
public void handleUnknown(String key, Object value) { hash = 47 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
StringBuilder sb = new StringBuilder(); hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
sb.append("Unknown property: '").append(key); return hash;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); }
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ProductionCountry other = (ProductionCountry) obj;
if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 47 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,128 +1,95 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author Stuart
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; public class ReleaseInfo extends AbstractJsonMapping {
import org.slf4j.LoggerFactory;
private static final long serialVersionUID = 1L;
/**
* /*
* @author Stuart * Properties
*/ */
public class ReleaseInfo implements Serializable { @JsonProperty("iso_3166_1")
private String country;
private static final long serialVersionUID = 1L; @JsonProperty("certification")
private String certification;
/* @JsonProperty("release_date")
* Logger private String releaseDate;
*/
private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class); //<editor-fold defaultstate="collapsed" desc="Getter methods">
/* public String getCertification() {
* Properties return certification;
*/ }
@JsonProperty("iso_3166_1")
private String country; public String getCountry() {
@JsonProperty("certification") return country;
private String certification; }
@JsonProperty("release_date")
private String releaseDate; public String getReleaseDate() {
return releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getCertification() {
return certification; public void setCertification(String certification) {
} this.certification = certification;
}
public String getCountry() {
return country; public void setCountry(String country) {
} this.country = country;
}
public String getReleaseDate() {
return releaseDate; public void setReleaseDate(String releaseDate) {
} this.releaseDate = releaseDate;
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter methods"> @Override
public void setCertification(String certification) { public boolean equals(Object obj) {
this.certification = certification; if (obj == null) {
} return false;
}
public void setCountry(String country) { if (getClass() != obj.getClass()) {
this.country = country; return false;
} }
final ReleaseInfo other = (ReleaseInfo) obj;
public void setReleaseDate(String releaseDate) { if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) {
this.releaseDate = releaseDate; return false;
} }
//</editor-fold> if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) {
return false;
/** }
* Handle unknown properties and print a message if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) {
* return false;
* @param key }
* @param value return true;
*/ }
@JsonAnySetter
public void handleUnknown(String key, Object value) { @Override
StringBuilder sb = new StringBuilder(); public int hashCode() {
sb.append("Unknown property: '").append(key); int hash = 3;
sb.append("' value: '").append(value).append("'"); hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0);
LOG.trace(sb.toString()); hash = 89 * hash + (this.certification != null ? this.certification.hashCode() : 0);
} hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash;
@Override }
public boolean equals(Object obj) { }
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ReleaseInfo other = (ReleaseInfo) obj;
if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) {
return false;
}
if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) {
return false;
}
if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0);
hash = 89 * hash + (this.certification != null ? this.certification.hashCode() : 0);
hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class Reviews implements Serializable { public class Reviews extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Reviews.class);
/* /*
* Properties * Properties
*/ */
@@ -86,23 +75,4 @@ public class Reviews implements Serializable {
this.url = url; this.url = url;
} }
// </editor-fold> // </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,88 +1,55 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; /**
import org.apache.commons.lang3.builder.ToStringBuilder; * @author Stuart
import org.apache.commons.lang3.builder.ToStringStyle; */
import org.slf4j.Logger; public class StatusCode extends AbstractJsonMapping {
import org.slf4j.LoggerFactory;
private static final long serialVersionUID = 1L;
/**
* /*
* @author Stuart * Properties
*/ */
public class StatusCode implements Serializable { @JsonProperty("status_code")
private int statusCode;
private static final long serialVersionUID = 1L; @JsonProperty("status_message")
private String statusMessage;
/*
* Logger //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public int getStatusCode() {
private static final Logger LOG = LoggerFactory.getLogger(StatusCode.class); return statusCode;
/* }
* Properties
*/ public void setStatusCode(int statusCode) {
@JsonProperty("status_code") this.statusCode = statusCode;
private int statusCode; }
@JsonProperty("status_message")
private String statusMessage; public String getStatusMessage() {
return statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public int getStatusCode() {
return statusCode; public void setStatusMessage(String statusMessage) {
} this.statusMessage = statusMessage;
}
public void setStatusCode(int statusCode) { }
this.statusCode = statusCode;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public String getStatusMessage() {
return statusMessage;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,202 +1,173 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder; /**
import org.apache.commons.lang3.builder.ToStringStyle; * @author stuart.boston
import org.slf4j.Logger; */
import org.slf4j.LoggerFactory; public class TmdbConfiguration extends AbstractJsonMapping {
/** private static final long serialVersionUID = 1L;
* /*
* @author stuart.boston * Properties
*/ */
public class TmdbConfiguration implements Serializable { @JsonProperty("base_url")
private String baseUrl;
private static final long serialVersionUID = 1L; @JsonProperty("secure_base_url")
/* private String secureBaseUrl;
* Logger @JsonProperty("poster_sizes")
*/ private List<String> posterSizes;
private static final Logger LOG = LoggerFactory.getLogger(TmdbConfiguration.class); @JsonProperty("backdrop_sizes")
/* private List<String> backdropSizes;
* Properties @JsonProperty("profile_sizes")
*/ private List<String> profileSizes;
@JsonProperty("base_url") @JsonProperty("logo_sizes")
private String baseUrl; private List<String> logoSizes;
@JsonProperty("secure_base_url")
private String secureBaseUrl; // <editor-fold defaultstate="collapsed" desc="Getter methods">//GEN-BEGIN:getterMethods
@JsonProperty("poster_sizes") public List<String> getBackdropSizes() {
private List<String> posterSizes; return backdropSizes;
@JsonProperty("backdrop_sizes") }
private List<String> backdropSizes;
@JsonProperty("profile_sizes") public String getBaseUrl() {
private List<String> profileSizes; return baseUrl;
@JsonProperty("logo_sizes") }
private List<String> logoSizes;
public List<String> getPosterSizes() {
// <editor-fold defaultstate="collapsed" desc="Getter methods">//GEN-BEGIN:getterMethods return posterSizes;
public List<String> getBackdropSizes() { }
return backdropSizes;
} public List<String> getProfileSizes() {
return profileSizes;
public String getBaseUrl() { }
return baseUrl;
} public List<String> getLogoSizes() {
return logoSizes;
public List<String> getPosterSizes() { }
return posterSizes;
} public String getSecureBaseUrl() {
return secureBaseUrl;
public List<String> getProfileSizes() { }
return profileSizes;
} // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">//GEN-BEGIN:setterMethods
public List<String> getLogoSizes() { public void setBackdropSizes(List<String> backdropSizes) {
return logoSizes; this.backdropSizes = backdropSizes;
} }
public String getSecureBaseUrl() { public void setBaseUrl(String baseUrl) {
return secureBaseUrl; this.baseUrl = baseUrl;
} }
// </editor-fold> public void setPosterSizes(List<String> posterSizes) {
// <editor-fold defaultstate="collapsed" desc="Setter methods">//GEN-BEGIN:setterMethods this.posterSizes = posterSizes;
public void setBackdropSizes(List<String> backdropSizes) { }
this.backdropSizes = backdropSizes;
} public void setProfileSizes(List<String> profileSizes) {
this.profileSizes = profileSizes;
public void setBaseUrl(String baseUrl) { }
this.baseUrl = baseUrl;
} public void setLogoSizes(List<String> logoSizes) {
this.logoSizes = logoSizes;
public void setPosterSizes(List<String> posterSizes) { }
this.posterSizes = posterSizes;
} public void setSecureBaseUrl(String secureBaseUrl) {
this.secureBaseUrl = secureBaseUrl;
public void setProfileSizes(List<String> profileSizes) { }
this.profileSizes = profileSizes; // </editor-fold>
}
/**
public void setLogoSizes(List<String> logoSizes) { * Copy the data from the passed object to this one
this.logoSizes = logoSizes; *
} * @param config
*/
public void setSecureBaseUrl(String secureBaseUrl) { public void clone(TmdbConfiguration config) {
this.secureBaseUrl = secureBaseUrl; backdropSizes = config.getBackdropSizes();
} baseUrl = config.getBaseUrl();
// </editor-fold> posterSizes = config.getPosterSizes();
profileSizes = config.getProfileSizes();
/** logoSizes = config.getLogoSizes();
* Copy the data from the passed object to this one }
*
* @param config /**
*/ * Check that the poster size is valid
public void clone(TmdbConfiguration config) { *
backdropSizes = config.getBackdropSizes(); * @param posterSize
baseUrl = config.getBaseUrl(); */
posterSizes = config.getPosterSizes(); public boolean isValidPosterSize(String posterSize) {
profileSizes = config.getProfileSizes(); if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
logoSizes = config.getLogoSizes(); return false;
} }
return posterSizes.contains(posterSize);
/** }
* Check that the poster size is valid
* /**
* @param posterSize * Check that the backdrop size is valid
*/ *
public boolean isValidPosterSize(String posterSize) { * @param backdropSize
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { */
return false; public boolean isValidBackdropSize(String backdropSize) {
} if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
return posterSizes.contains(posterSize); return false;
} }
return backdropSizes.contains(backdropSize);
/** }
* Check that the backdrop size is valid
* /**
* @param backdropSize * Check that the profile size is valid
*/ *
public boolean isValidBackdropSize(String backdropSize) { * @param profileSize
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { */
return false; public boolean isValidProfileSize(String profileSize) {
} if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
return backdropSizes.contains(backdropSize); return false;
} }
return profileSizes.contains(profileSize);
/** }
* Check that the profile size is valid
* /**
* @param profileSize * Check that the logo size is valid
*/ *
public boolean isValidProfileSize(String profileSize) { * @param logoSize
if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { */
return false; public boolean isValidLogoSize(String logoSize) {
} if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) {
return profileSizes.contains(profileSize); return false;
} }
return logoSizes.contains(logoSize);
/** }
* Check that the logo size is valid
* /**
* @param logoSize * Check to see if the size is valid for any of the images types
*/ *
public boolean isValidLogoSize(String logoSize) { * @param sizeToCheck
if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { */
return false; public boolean isValidSize(String sizeToCheck) {
} return (isValidPosterSize(sizeToCheck)
return logoSizes.contains(logoSize); || isValidBackdropSize(sizeToCheck)
} || isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck));
/** }
* Check to see if the size is valid for any of the images types }
*
* @param sizeToCheck
*/
public boolean isValidSize(String sizeToCheck) {
return (isValidPosterSize(sizeToCheck)
|| isValidBackdropSize(sizeToCheck)
|| isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck));
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,91 +1,70 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger; public class TokenAuthorisation {
import org.slf4j.LoggerFactory;
/*
public class TokenAuthorisation { * Properties
/* */
* Logger @JsonProperty("expires_at")
*/ private String expires;
private static final Logger LOG = LoggerFactory.getLogger(TokenAuthorisation.class); @JsonProperty("request_token")
/* private String requestToken;
* Properties @JsonProperty("success")
*/ private Boolean success;
@JsonProperty("expires_at")
private String expires; // <editor-fold defaultstate="collapsed" desc="Getter methods">
@JsonProperty("request_token") public String getExpires() {
private String requestToken; return expires;
@JsonProperty("success") }
private Boolean success;
public String getRequestToken() {
// <editor-fold defaultstate="collapsed" desc="Getter methods"> return requestToken;
public String getExpires() { }
return expires;
} public Boolean getSuccess() {
return success;
public String getRequestToken() { }
return requestToken; // </editor-fold>
}
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public Boolean getSuccess() { public void setExpires(String expires) {
return success; this.expires = expires;
} }
// </editor-fold>
public void setRequestToken(String requestToken) {
// <editor-fold defaultstate="collapsed" desc="Setter methods"> this.requestToken = requestToken;
public void setExpires(String expires) { }
this.expires = expires;
} public void setSuccess(Boolean success) {
this.success = success;
public void setRequestToken(String requestToken) { }
this.requestToken = requestToken; // </editor-fold>
}
@Override
public void setSuccess(Boolean success) { public String toString() {
this.success = success; return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
} }
// </editor-fold> }
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,122 +1,100 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger; public class TokenSession {
import org.slf4j.LoggerFactory;
/*
public class TokenSession { * Properties
/* */
* Logger @JsonProperty("session_id")
*/ private String sessionId;
@JsonProperty("success")
private static final Logger LOG = LoggerFactory.getLogger(TokenSession.class); private Boolean success;
/* @JsonProperty("status_code")
* Properties private String statusCode;
*/ @JsonProperty("status_message")
@JsonProperty("session_id") private String statusMessage;
private String sessionId; @JsonProperty("guest_session_id")
@JsonProperty("success") private String guestSessionId;
private Boolean success; @JsonProperty("expires_at")
@JsonProperty("status_code") private String expiresAt;
private String statusCode;
@JsonProperty("status_message") // <editor-fold defaultstate="collapsed" desc="Getter methods">
private String statusMessage; public String getSessionId() {
@JsonProperty("guest_session_id") return sessionId;
private String guestSessionId; }
@JsonProperty("expires_at")
private String expiresAt; public Boolean getSuccess() {
return success;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getSessionId() {
return sessionId; public String getStatusCode() {
} return statusCode;
}
public Boolean getSuccess() {
return success; public String getStatusMessage() {
} return statusMessage;
}
public String getStatusCode() {
return statusCode; public String getGuestSessionId() {
} return guestSessionId;
}
public String getStatusMessage() {
return statusMessage; public String getExpiresAt() {
} return expiresAt;
}
public String getGuestSessionId() { // </editor-fold>
return guestSessionId;
} // <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setSessionId(String sessionId) {
public String getExpiresAt() { this.sessionId = sessionId;
return expiresAt; }
}
// </editor-fold> public void setSuccess(Boolean success) {
this.success = success;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setSessionId(String sessionId) {
this.sessionId = sessionId; public void setStatusCode(String statusCode) {
} this.statusCode = statusCode;
}
public void setSuccess(Boolean success) {
this.success = success; public void setStatusMessage(String statusMessage) {
} this.statusMessage = statusMessage;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode; public void setGuestSessionId(String guestSessionId) {
} this.guestSessionId = guestSessionId;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage; public void setExpiresAt(String expiresAt) {
} this.expiresAt = expiresAt;
}
public void setGuestSessionId(String guestSessionId) { // </editor-fold>
this.guestSessionId = guestSessionId;
} @Override
public String toString() {
public void setExpiresAt(String expiresAt) { return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
this.expiresAt = expiresAt; }
} }
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,139 +1,105 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; /**
import java.io.Serializable; * @author Stuart
import org.apache.commons.lang3.builder.ToStringBuilder; */
import org.apache.commons.lang3.builder.ToStringStyle; public class Trailer extends AbstractJsonMapping {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; private static final long serialVersionUID = 1L;
/** /*
* * Website sources
* @author Stuart */
*/ public static final String WEBSITE_YOUTUBE = "youtube";
public class Trailer implements Serializable { public static final String WEBSITE_QUICKTIME = "quicktime";
/*
private static final long serialVersionUID = 1L; * Properties
*/
/* private String name;
* Logger private String size;
*/ private String source;
private static final Logger LOG = LoggerFactory.getLogger(Trailer.class); private String website; // The website of the trailer
/*
* Website sources //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public String getName() {
public static final String WEBSITE_YOUTUBE = "youtube"; return name;
public static final String WEBSITE_QUICKTIME = "quicktime"; }
/*
* Properties public String getSize() {
*/ return size;
private String name; }
private String size;
private String source; public String getSource() {
private String website; // The website of the trailer return source;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getName() { public String getWebsite() {
return name; return website;
} }
public String getSize() { public void setName(String name) {
return size; this.name = name;
} }
public String getSource() { public void setSize(String size) {
return source; this.size = size;
} }
public String getWebsite() { public void setSource(String source) {
return website; this.source = source;
} }
//</editor-fold>
public void setWebsite(String website) {
//<editor-fold defaultstate="collapsed" desc="Setter methods"> this.website = website;
public void setName(String name) { }
this.name = name;
} @Override
public boolean equals(Object obj) {
public void setSize(String size) { if (obj == null) {
this.size = size; return false;
} }
if (getClass() != obj.getClass()) {
public void setSource(String source) { return false;
this.source = source; }
} final Trailer other = (Trailer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
public void setWebsite(String website) { return false;
this.website = website; }
} if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
//</editor-fold> return false;
}
/** if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
* Handle unknown properties and print a message return false;
* }
* @param key return true;
* @param value }
*/
@JsonAnySetter @Override
public void handleUnknown(String key, Object value) { public int hashCode() {
StringBuilder sb = new StringBuilder(); int hash = 7;
sb.append("Unknown property: '").append(key); hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
sb.append("' value: '").append(value).append("'"); hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
LOG.trace(sb.toString()); hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
} hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash;
@Override }
public boolean equals(Object obj) { }
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Trailer other = (Trailer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
return false;
}
if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,128 +1,102 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable; import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; /**
import org.slf4j.Logger; * @author Stuart
import org.slf4j.LoggerFactory; */
public class Translation extends AbstractJsonMapping {
/**
* private static final long serialVersionUID = 1L;
* @author Stuart
*/ /*
public class Translation implements Serializable { * Properties
*/
private static final long serialVersionUID = 1L; @JsonProperty("english_name")
private String englishName;
/* @JsonProperty("iso_639_1")
* Logger private String isoCode;
*/ @JsonProperty("name")
private static final Logger LOG = LoggerFactory.getLogger(Translation.class); private String name;
/*
* Properties //<editor-fold defaultstate="collapsed" desc="Getter methods">
*/ public String getEnglishName() {
@JsonProperty("english_name") return englishName;
private String englishName; }
@JsonProperty("iso_639_1")
private String isoCode; public String getIsoCode() {
@JsonProperty("name") return isoCode;
private String name; }
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public String getName() {
public String getEnglishName() { return name;
return englishName; }
}
public void setEnglishName(String englishName) {
public String getIsoCode() { this.englishName = englishName;
return isoCode; }
}
public void setIsoCode(String isoCode) {
public String getName() { this.isoCode = isoCode;
return name; }
}
//</editor-fold> public void setName(String name) {
this.name = name;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setEnglishName(String englishName) {
this.englishName = englishName; @Override
} public boolean equals(Object obj) {
if (obj == null) {
public void setIsoCode(String isoCode) { return false;
this.isoCode = isoCode; }
} if (getClass() != obj.getClass()) {
return false;
public void setName(String name) { }
this.name = name; final Translation other = (Translation) obj;
} if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) {
//</editor-fold> return false;
}
/** if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
* Handle unknown properties and print a message return false;
* }
* @param key if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
* @param value return false;
*/ }
@JsonAnySetter return true;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key); @Override
sb.append("' value: '").append(value).append("'"); public int hashCode() {
LOG.trace(sb.toString()); int hash = 3;
} hash = 29 * hash + (this.englishName != null ? this.englishName.hashCode() : 0);
hash = 29 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
@Override hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0);
public boolean equals(Object obj) { return hash;
if (obj == null) { }
return false;
} @Override
if (getClass() != obj.getClass()) { public String toString() {
return false; return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
} }
final Translation other = (Translation) obj; }
if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) {
return false;
}
if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 29 * hash + (this.englishName != null ? this.englishName.hashCode() : 0);
hash = 29 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -1,289 +1,335 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.tools; package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.MovieDbException; import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.BufferedReader; import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException; import com.omertron.themoviedbapi.MovieDbException;
import java.io.InputStreamReader; import org.apache.commons.codec.binary.Base64;
import java.io.StringWriter; import org.slf4j.Logger;
import java.net.HttpURLConnection; import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
import java.net.URL; import java.io.*;
import java.net.URLConnection; import java.net.HttpURLConnection;
import java.nio.charset.Charset; import java.net.MalformedURLException;
import java.nio.charset.UnsupportedCharsetException; import java.net.URL;
import java.util.HashMap; import java.net.URLConnection;
import java.util.List; import java.nio.charset.Charset;
import java.util.Map; import java.nio.charset.UnsupportedCharsetException;
import java.util.regex.Matcher; import java.util.HashMap;
import java.util.regex.Pattern; import java.util.List;
import org.apache.commons.codec.binary.Base64; import java.util.Map;
import org.slf4j.Logger; import java.util.regex.Matcher;
import org.slf4j.LoggerFactory; import java.util.regex.Pattern;
/** /**
* Web browser with simple cookies support * Web browser with simple cookies support
*/ */
public final class WebBrowser { public final class WebBrowser {
private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class); private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class);
private static Map<String, String> browserProperties = new HashMap<String, String>(); private static Map<String, String> browserProperties = new HashMap<String, String>();
private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>(); private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>();
private static String proxyHost = null; private static String proxyHost = null;
private static String proxyPort = null; private static String proxyPort = null;
private static String proxyUsername = null; private static String proxyUsername = null;
private static String proxyPassword = null; private static String proxyPassword = null;
private static String proxyEncodedPassword = null; private static String proxyEncodedPassword = null;
private static int webTimeoutConnect = 25000; // 25 second timeout private static int webTimeoutConnect = 25000; // 25 second timeout
private static int webTimeoutRead = 90000; // 90 second timeout private static int webTimeoutRead = 90000; // 90 second timeout
// Hide the constructor // Hide the constructor
protected WebBrowser() { protected WebBrowser() {
// prevents calls from subclass // prevents calls from subclass
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** /**
* Populate the browser properties * Populate the browser properties
*/ */
private static void populateBrowserProperties() { private static void populateBrowserProperties() {
if (browserProperties.isEmpty()) { if (browserProperties.isEmpty()) {
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
browserProperties.put("Accept", "application/json"); browserProperties.put("Accept", "application/json");
} browserProperties.put("Content-type", "application/json");
} }
}
public static String request(String url) throws MovieDbException {
try { public static String request(String url) throws MovieDbException {
return request(new URL(url)); try {
} catch (MalformedURLException ex) { return request(new URL(url));
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); } catch (MalformedURLException ex) {
} throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
} }
}
public static URLConnection openProxiedConnection(URL url) throws MovieDbException {
try { public static URLConnection openProxiedConnection(URL url) throws MovieDbException {
if (proxyHost != null) { try {
System.getProperties().put("proxySet", "true"); if (proxyHost != null) {
System.getProperties().put("proxyHost", proxyHost); System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyPort", proxyPort); System.getProperties().put("proxyHost", proxyHost);
} System.getProperties().put("proxyPort", proxyPort);
}
URLConnection cnx = url.openConnection();
URLConnection cnx = url.openConnection();
if (proxyUsername != null) {
cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); if (proxyUsername != null) {
} cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
}
return cnx;
} catch (IOException ex) { return cnx;
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); } catch (IOException ex) {
} throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
} }
}
public static String request(URL url) throws MovieDbException {
StringWriter content = null; public static String request(URL url) throws MovieDbException {
return request(url, null);
try { }
content = new StringWriter();
public static String request(URL url, String jsonBody) throws MovieDbException {
BufferedReader in = null; return request(url, jsonBody, false);
URLConnection cnx = null; }
try {
cnx = openProxiedConnection(url); public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
sendHeader(cnx); StringWriter content = null;
readHeader(cnx);
try {
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); content = new StringWriter();
String line;
while ((line = in.readLine()) != null) { BufferedReader in = null;
content.write(line); HttpURLConnection cnx = null;
} OutputStreamWriter wr = null;
} finally { try {
if (in != null) { cnx = (HttpURLConnection) openProxiedConnection(url);
in.close();
} if (isDeleteRequest) {
cnx.setDoOutput(true);
if (cnx instanceof HttpURLConnection) { cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
((HttpURLConnection) cnx).disconnect(); cnx.setRequestMethod("DELETE");
} }
}
return content.toString(); sendHeader(cnx);
} catch (IOException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex); if (jsonBody != null) {
} finally { cnx.setDoOutput(true);
if (content != null) { wr = new OutputStreamWriter(cnx.getOutputStream());
try { wr.write(jsonBody);
content.close(); }
} catch (IOException ex) {
LOG.debug("Failed to close connection: " + ex.getMessage()); readHeader(cnx);
}
} // http://stackoverflow.com/questions/4633048/httpurlconnection-reading-response-content-on-403-error
} if (cnx.getResponseCode() >= 400) {
} in = new BufferedReader(new InputStreamReader(cnx.getErrorStream(), getCharset(cnx)));
} else {
private static void sendHeader(URLConnection cnx) { in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
populateBrowserProperties(); }
// send browser properties String line;
for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) { while ((line = in.readLine()) != null) {
cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); content.write(line);
} }
// send cookies } finally {
String cookieHeader = createCookieHeader(cnx); if (wr != null) {
if (!cookieHeader.isEmpty()) { wr.flush();
cnx.setRequestProperty("Cookie", cookieHeader); wr.close();
} }
}
if (in != null) {
private static String createCookieHeader(URLConnection cnx) { in.close();
String host = cnx.getURL().getHost(); }
StringBuilder cookiesHeader = new StringBuilder();
for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) { if (cnx instanceof HttpURLConnection) {
if (host.endsWith(domainCookies.getKey())) { ((HttpURLConnection) cnx).disconnect();
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) { }
cookiesHeader.append(cookie.getKey()); }
cookiesHeader.append("="); return content.toString();
cookiesHeader.append(cookie.getValue()); } catch (IOException ex) {
cookiesHeader.append(";"); throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex);
} } finally {
} if (content != null) {
} try {
if (cookiesHeader.length() > 0) { content.close();
// remove last ; char } catch (IOException ex) {
cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); LOG.debug("Failed to close connection: " + ex.getMessage());
} }
return cookiesHeader.toString(); }
} }
}
private static void readHeader(URLConnection cnx) {
// read new cookies and update our cookies private static void sendHeader(URLConnection cnx) {
for (Map.Entry<String, List<String>> header : cnx.getHeaderFields().entrySet()) { populateBrowserProperties();
if ("Set-Cookie".equals(header.getKey())) {
for (String cookieHeader : header.getValue()) { // send browser properties
String[] cookieElements = cookieHeader.split(" *; *"); for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) {
if (cookieElements.length >= 1) { cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
String[] firstElem = cookieElements[0].split(" *= *"); }
String cookieName = firstElem[0]; // send cookies
String cookieValue = firstElem.length > 1 ? firstElem[1] : null; String cookieHeader = createCookieHeader(cnx);
String cookieDomain = null; if (!cookieHeader.isEmpty()) {
// find cookie domain cnx.setRequestProperty("Cookie", cookieHeader);
for (int i = 1; i < cookieElements.length; i++) { }
String[] cookieElement = cookieElements[i].split(" *= *"); }
if ("domain".equals(cookieElement[0])) {
cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; private static String createCookieHeader(URLConnection cnx) {
break; String host = cnx.getURL().getHost();
} StringBuilder cookiesHeader = new StringBuilder();
} for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) {
if (cookieDomain == null) { if (host.endsWith(domainCookies.getKey())) {
// if domain isn't set take current host for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
cookieDomain = cnx.getURL().getHost(); cookiesHeader.append(cookie.getKey());
} cookiesHeader.append("=");
Map<String, String> domainCookies = cookies.get(cookieDomain); cookiesHeader.append(cookie.getValue());
if (domainCookies == null) { cookiesHeader.append(";");
domainCookies = new HashMap<String, String>(); }
cookies.put(cookieDomain, domainCookies); }
} }
// add or replace cookie if (cookiesHeader.length() > 0) {
domainCookies.put(cookieName, cookieValue); // remove last ; char
} cookiesHeader.deleteCharAt(cookiesHeader.length() - 1);
} }
} return cookiesHeader.toString();
} }
}
private static void readHeader(URLConnection cnx) {
private static Charset getCharset(URLConnection cnx) { // read new cookies and update our cookies
Charset charset = null; for (Map.Entry<String, List<String>> header : cnx.getHeaderFields().entrySet()) {
// content type will be string like "text/html; charset=UTF-8" or "text/html" if ("Set-Cookie".equals(header.getKey())) {
String contentType = cnx.getContentType(); for (String cookieHeader : header.getValue()) {
if (contentType != null) { String[] cookieElements = cookieHeader.split(" *; *");
// changed 'charset' to 'harset' in regexp because some sites send 'Charset' if (cookieElements.length >= 1) {
Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); String[] firstElem = cookieElements[0].split(" *= *");
if (m.find()) { String cookieName = firstElem[0];
String encoding = m.group(1); String cookieValue = firstElem.length > 1 ? firstElem[1] : null;
try { String cookieDomain = null;
charset = Charset.forName(encoding); // find cookie domain
} catch (UnsupportedCharsetException e) { for (int i = 1; i < cookieElements.length; i++) {
// there will be used default charset String[] cookieElement = cookieElements[i].split(" *= *");
} if ("domain".equals(cookieElement[0])) {
} cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null;
} break;
if (charset == null) { }
charset = Charset.defaultCharset(); }
} if (cookieDomain == null) {
// if domain isn't set take current host
return charset; cookieDomain = cnx.getURL().getHost();
} }
Map<String, String> domainCookies = cookies.get(cookieDomain);
public static String getProxyHost() { if (domainCookies == null) {
return proxyHost; domainCookies = new HashMap<String, String>();
} cookies.put(cookieDomain, domainCookies);
}
public static void setProxyHost(String myProxyHost) { // add or replace cookie
WebBrowser.proxyHost = myProxyHost; domainCookies.put(cookieName, cookieValue);
} }
}
public static String getProxyPort() { }
return proxyPort; }
} }
public static void setProxyPort(String myProxyPort) { private static Charset getCharset(URLConnection cnx) {
WebBrowser.proxyPort = myProxyPort; Charset charset = null;
} // content type will be string like "text/html; charset=UTF-8" or "text/html"
String contentType = cnx.getContentType();
public static String getProxyUsername() { if (contentType != null) {
return proxyUsername; // changed 'charset' to 'harset' in regexp because some sites send 'Charset'
} Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType);
if (m.find()) {
public static void setProxyUsername(String myProxyUsername) { String encoding = m.group(1);
WebBrowser.proxyUsername = myProxyUsername; try {
} charset = Charset.forName(encoding);
} catch (UnsupportedCharsetException e) {
public static String getProxyPassword() { // there will be used default charset
return proxyPassword; }
} }
}
public static void setProxyPassword(String myProxyPassword) { if (charset == null) {
WebBrowser.proxyPassword = myProxyPassword; charset = Charset.defaultCharset();
}
if (proxyUsername != null) {
proxyEncodedPassword = proxyUsername + ":" + proxyPassword; return charset;
proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes())); }
}
} public static String getProxyHost() {
return proxyHost;
public static int getWebTimeoutConnect() { }
return webTimeoutConnect;
} public static void setProxyHost(String myProxyHost) {
WebBrowser.proxyHost = myProxyHost;
public static int getWebTimeoutRead() { }
return webTimeoutRead;
} public static String getProxyPort() {
return proxyPort;
public static void setWebTimeoutConnect(int webTimeoutConnect) { }
WebBrowser.webTimeoutConnect = webTimeoutConnect;
} public static void setProxyPort(String myProxyPort) {
WebBrowser.proxyPort = myProxyPort;
public static void setWebTimeoutRead(int webTimeoutRead) { }
WebBrowser.webTimeoutRead = webTimeoutRead;
} public static String getProxyUsername() {
} return proxyUsername;
}
public static void setProxyUsername(String myProxyUsername) {
WebBrowser.proxyUsername = myProxyUsername;
}
public static String getProxyPassword() {
return proxyPassword;
}
public static void setProxyPassword(String myProxyPassword) {
WebBrowser.proxyPassword = myProxyPassword;
if (proxyUsername != null) {
proxyEncodedPassword = proxyUsername + ":" + proxyPassword;
proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes()));
}
}
public static int getWebTimeoutConnect() {
return webTimeoutConnect;
}
public static int getWebTimeoutRead() {
return webTimeoutRead;
}
public static void setWebTimeoutConnect(int webTimeoutConnect) {
WebBrowser.webTimeoutConnect = webTimeoutConnect;
}
public static void setWebTimeoutRead(int webTimeoutRead) {
WebBrowser.webTimeoutRead = webTimeoutRead;
}
/**
* Use Jackson to convert Map to JSON string.
*/
public static String convertToJson(Map<String, ?> map) throws MovieDbException {
try {
return new ObjectMapper().writeValueAsString(map);
} catch (JsonProcessingException jpe) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.MAPPING_FAILED, "JSON conversion failed", jpe);
}
}
}
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* *
* @author Stuart * @author Stuart
*/ */
public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages { public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages, IWrapperDates {
/* /*
* Properties * Properties
*/ */
@@ -37,6 +37,8 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
private int totalPages; private int totalPages;
@JsonProperty("total_results") @JsonProperty("total_results")
private int totalResults; private int totalResults;
@JsonProperty("dates")
private ResultDates dates = new ResultDates();
public AbstractWrapperAll(Class classToLog) { public AbstractWrapperAll(Class classToLog) {
super(classToLog); super(classToLog);
@@ -57,6 +59,11 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
return totalResults; return totalResults;
} }
@Override
public ResultDates getDates() {
return dates;
}
@Override @Override
public void setPage(int page) { public void setPage(int page) {
this.page = page; this.page = page;
@@ -71,4 +78,9 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
public void setTotalResults(int totalResults) { public void setTotalResults(int totalResults) {
this.totalResults = totalResults; this.totalResults = totalResults;
} }
@Override
public void setDates(ResultDates dates) {
this.dates = dates;
}
} }
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2004-2013 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;
public interface IWrapperDates {
ResultDates getDates();
void setDates(ResultDates dates);
}
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2004-2013 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.omertron.themoviedbapi.model.*;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Stuart
*/
public class ResultDates implements Serializable {
private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ResultDates.class);
/*
* Properties
*/
@JsonProperty("minimum")
private String minimum = "";
@JsonProperty("maximum")
private String maximum = "";
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getMinimum() {
return minimum;
}
public String getMaximum() {
return maximum;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setMinimum(String minimum) {
this.minimum = minimum;
}
public void setMaximum(String maximum) {
this.maximum = maximum;
}
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
}
@@ -0,0 +1,25 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDbList;
import java.util.List;
public class WrapperMovieDbList extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieDbList> lists;
public WrapperMovieDbList() {
super(WrapperMovieDbList.class);
}
public List<MovieDbList> getLists() {
return lists;
}
public void setLists(List<MovieDbList> lists) {
this.lists = lists;
}
}
@@ -19,39 +19,20 @@
*/ */
package com.omertron.themoviedbapi; package com.omertron.themoviedbapi;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.*;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ChangedItem;
import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.Discover;
import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model.JobDepartment;
import com.omertron.themoviedbapi.model.Keyword;
import com.omertron.themoviedbapi.model.KeywordMovie;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieDbList;
import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCredit;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model.Reviews;
import com.omertron.themoviedbapi.model.TmdbConfiguration;
import com.omertron.themoviedbapi.model.TokenAuthorisation;
import com.omertron.themoviedbapi.model.TokenSession;
import com.omertron.themoviedbapi.model.Trailer;
import com.omertron.themoviedbapi.model.Translation;
import com.omertron.themoviedbapi.results.TmdbResultsList; import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap; import com.omertron.themoviedbapi.results.TmdbResultsMap;
import java.io.IOException;
import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.junit.*; import org.junit.*;
import static org.junit.Assert.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import static org.junit.Assert.*;
/** /**
* Test cases for TheMovieDbApi API * Test cases for TheMovieDbApi API
* *
@@ -69,7 +50,7 @@ public class TheMovieDbApiTest {
private static final int ID_MOVIE_THE_AVENGERS = 24428; private static final int ID_MOVIE_THE_AVENGERS = 24428;
private static final int ID_COLLECTION_STAR_WARS = 10; private static final int ID_COLLECTION_STAR_WARS = 10;
private static final int ID_PERSON_BRUCE_WILLIS = 62; private static final int ID_PERSON_BRUCE_WILLIS = 62;
private static final int ID_COMPANY_LUCASFILM = 1; private static final int ID_COMPANY = 2;
private static final String COMPANY_NAME = "Marvel Studios"; private static final String COMPANY_NAME = "Marvel Studios";
private static final int ID_GENRE_ACTION = 28; private static final int ID_GENRE_ACTION = 28;
private static final String ID_KEYWORD = "1721"; private static final String ID_KEYWORD = "1721";
@@ -77,6 +58,9 @@ public class TheMovieDbApiTest {
private static final String LANGUAGE_DEFAULT = ""; private static final String LANGUAGE_DEFAULT = "";
private static final String LANGUAGE_ENGLISH = "en"; private static final String LANGUAGE_ENGLISH = "en";
private static final String LANGUAGE_RUSSIAN = "ru"; private static final String LANGUAGE_RUSSIAN = "ru";
// session and account id of test users named 'apitests'
private static final String SESSION_ID_APITESTS = "63c85deb39337e29b69d78265eb28d639cbd6f72";
private static final int ACCOUNT_ID_APITESTS = 6065849;
public TheMovieDbApiTest() throws MovieDbException { public TheMovieDbApiTest() throws MovieDbException {
} }
@@ -115,6 +99,51 @@ public class TheMovieDbApiTest {
LOG.info(tmdbConfig.toString()); LOG.info(tmdbConfig.toString());
} }
@Test
public void testAccount() throws MovieDbException {
Account account = tmdb.getAccount(SESSION_ID_APITESTS);
// Make sure properties are extracted correctly
assertEquals(account.getUserName(), "apitests");
assertEquals(account.getId(), ACCOUNT_ID_APITESTS);
}
@Ignore("Session required")
public void testWatchList() throws MovieDbException {
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
// add a movie
tmdb.addToWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
List<MovieDb> watchList = tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.removeFromWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
}
@Ignore("Session required")
public void testFavorites() throws MovieDbException {
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
// add a movie
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, true);
List<MovieDb> watchList = tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, false);
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
}
/** /**
* Test of searchMovie method, of class TheMovieDbApi. * Test of searchMovie method, of class TheMovieDbApi.
*/ */
@@ -413,8 +442,9 @@ public class TheMovieDbApiTest {
@Test @Test
public void testGetCompanyInfo() throws MovieDbException { public void testGetCompanyInfo() throws MovieDbException {
LOG.info("getCompanyInfo"); LOG.info("getCompanyInfo");
Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); Company company = tmdb.getCompanyInfo(ID_COMPANY);
assertTrue("No company information found", company.getCompanyId() > 0); assertTrue("No company information found", company.getCompanyId() > 0);
assertNotNull("No parent company found", company.getParentCompany());
} }
/** /**
@@ -423,7 +453,7 @@ public class TheMovieDbApiTest {
@Test @Test
public void testGetCompanyMovies() throws MovieDbException { public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies"); LOG.info("getCompanyMovies");
TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertTrue("No company movies found", !result.getResults().isEmpty()); assertTrue("No company movies found", !result.getResults().isEmpty());
} }
@@ -504,12 +534,13 @@ public class TheMovieDbApiTest {
* *
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*/ */
@Ignore("Session required")
public void testGetSessionToken() throws Exception { public void testGetSessionToken() throws Exception {
LOG.info("getSessionToken"); LOG.info("getSessionToken");
TokenAuthorisation token = tmdb.getAuthorisationToken(); TokenAuthorisation token = tmdb.getAuthorisationToken();
assertFalse("Token is null", token == null); assertFalse("Token is null", token == null);
assertTrue("Token is not valid", token.getSuccess()); assertTrue("Token is not valid", token.getSuccess());
LOG.info(token.toString()); LOG.info("Token: {}", token.toString());
TokenSession result = tmdb.getSessionToken(token); TokenSession result = tmdb.getSessionToken(token);
assertFalse("Session token is null", result == null); assertFalse("Session token is null", result == null);
@@ -612,16 +643,57 @@ public class TheMovieDbApiTest {
* *
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*/ */
@Ignore("Not ready yet") @Ignore("Session required")
public void testPostMovieRating() throws Exception { public void testMovieRating() throws Exception {
LOG.info("postMovieRating"); LOG.info("postMovieRating");
String sessionId = ""; Integer movieID = 68724;
String rating = ""; Integer rating = new Random().nextInt(10) + 1;
boolean expResult = false;
boolean result = tmdb.postMovieRating(sessionId, rating); boolean wasPosted = tmdb.postMovieRating(SESSION_ID_APITESTS, movieID, rating);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail. assertNotNull(wasPosted);
fail("The test case is a prototype."); assertTrue(wasPosted);
// get all rated movies
List<MovieDb> ratedMovies = tmdb.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertTrue(ratedMovies.size() > 0);
// make sure that we find the movie and it is rated correctly
boolean foundMovie = false;
for (MovieDb movie : ratedMovies) {
if (movie.getId() == movieID) {
assertEquals(movie.getUserRating(), (float) rating, 0);
foundMovie = true;
}
}
assertTrue(foundMovie);
}
@Ignore("Session required")
public void testMovieLists() throws Exception {
Integer movieID = 68724;
// use a random name to avoid that we clash we leftovers of incomplete test runs
String name = "test list " + new Random().nextInt(100);
// create the list
String listId = tmdb.createList(SESSION_ID_APITESTS, name, "api testing only");
// add a movie, and test that it is on the list now
tmdb.addMovieToList(SESSION_ID_APITESTS, listId, movieID);
MovieDbList list = tmdb.getList(listId);
assertNotNull("Movie list returned was null", list);
assertEquals("Unexpected number of items returned", 1, list.getItemCount());
assertEquals((int) movieID, list.getItems().get(0).getId());
// now remove the movie
tmdb.removeMovieFromList(SESSION_ID_APITESTS, listId, movieID);
assertEquals(tmdb.getList(listId).getItemCount(), 0);
// delete the test list
StatusCode statusCode = tmdb.deleteMovieList(SESSION_ID_APITESTS, listId);
assertEquals(statusCode.getStatusCode(), 13);
} }
/** /**