48 Commits

Author SHA1 Message Date
Omertron eaf5849a43 [maven-release-plugin] prepare release themoviedbapi-3.8 2013-11-07 11:05:57 +01:00
Stuart Boston 231f60624b Tidy up log error messages 2013-11-07 09:52:21 +00:00
Stuart Boston 3b1855d75c Remove unused imports 2013-11-07 09:50:06 +00:00
Stuart Boston 0cfa4d0dd4 Update README.md 2013-11-07 08:44:29 +00:00
Stuart Boston 971ee44375 Remove unused comments 2013-11-01 12:47:52 +00:00
Stuart Boston 359a0d56a3 Added "type" to Trailer 2013-11-01 12:29:55 +00:00
Stuart Boston 8eea8c796a Update handlerUnknown code
Output the class that caused the unknown issue
2013-11-01 12:28:53 +00:00
Stuart Boston 82e9c5b06f Trim test logging message 2013-11-01 12:26:15 +00:00
Stuart Boston 57691ed17f Remove unused imports 2013-10-29 15:56:00 +00:00
Stuart Boston b705a85566 Add badges 2013-10-22 16:04:43 +01:00
Stuart Boston db4f3e6f80 Minor updates 2013-10-22 13:44:42 +01:00
Stuart Boston 9eed62c8d7 Updated javadoc 2013-10-22 12:03:25 +01:00
Stuart Boston 51e5166233 Throw MovieDbException if movie ID not found
Rather than pass a seemingly valid object back to the caller, this
change will throw a "MOVIE_ID_NOT_FOUND" exception to the caller.
Affects getMovieInfo and getMovieInfoImdb methods
Fixes #8
2013-10-02 09:15:50 +01:00
Stuart Boston dd5176d6c6 Add gitattributes file
Update line endings
2013-10-01 14:10:54 +01:00
Stuart Boston 6448542fb4 Merge pull request #7 from fcojean/master
Implemented MovieChangesList
2013-09-26 11:37:19 +01:00
Stuart Boston 1ac805bed3 Add missing Serializable 2013-09-25 09:58:24 +01:00
Stuart Boston 2ef41457d0 Change logging for abstract wrapper 2013-09-25 09:48:47 +01:00
Stuart Boston d3338cc106 Remove unused imports 2013-09-25 09:38:30 +01:00
Stuart Boston 2c5569d53d Add language and country to account information 2013-09-25 09:33:44 +01:00
Stuart Boston 546a1e0d93 Update README.md 2013-09-20 10:43:35 +01:00
Stuart Boston 3b503e78ef Add exceptions for unknown request types 2013-09-08 11:10:21 +01:00
Stuart Boston 4cb0314c56 Use pooling client for requests 2013-09-08 10:36:54 +01:00
Omertron 95b3a4dd36 [maven-release-plugin] prepare for next development iteration 2013-08-23 10:22:03 +02:00
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
83 changed files with 7359 additions and 7086 deletions
+22
View File
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
+9 -9
View File
@@ -1,9 +1,9 @@
*.class *.class
# Package Files # # Package Files #
*.jar *.jar
*.war *.war
*.ear *.ear
/target/ /target/
/nbactions.xml /nbactions.xml
+12 -12
View File
@@ -1,12 +1,12 @@
package com.darylbeattie.movies.util; package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target(value=ElementType.METHOD) @Target(value=ElementType.METHOD)
@Retention(value=RetentionPolicy.RUNTIME) @Retention(value=RetentionPolicy.RUNTIME)
public @interface JsonAnySetter { public @interface JsonAnySetter {
} }
+12 -12
View File
@@ -1,12 +1,12 @@
package com.darylbeattie.movies.util; package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface JsonProperty { public @interface JsonProperty {
String value() default ""; String value() default "";
} }
+12 -12
View File
@@ -1,12 +1,12 @@
package com.darylbeattie.movies.util; package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface JsonRootName { public @interface JsonRootName {
String value() default ""; String value() default "";
} }
+68 -68
View File
@@ -1,69 +1,69 @@
package com.darylbeattie.movies.util; package com.darylbeattie.movies.util;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.util.List; import java.util.List;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
public class ObjectMapper { public class ObjectMapper {
/** /**
* This takes a JSON string and creates (and populates) an object of the given class * This takes a JSON string and creates (and populates) an object of the given class
* with the data from that JSON string. It mimics the method signature of the jackson * with the data from that JSON string. It mimics the method signature of the jackson
* JSON API, so that we don't have to import the jackson library into this application. * JSON API, so that we don't have to import the jackson library into this application.
* *
* @param jsonString The JSON string to parse. * @param jsonString The JSON string to parse.
* @param objClass The class of object we want to create. * @param objClass The class of object we want to create.
* @return The instantiation of that class, populated with data from the JSON object. * @return The instantiation of that class, populated with data from the JSON object.
* @throws IOException If there was any kind of issue. * @throws IOException If there was any kind of issue.
*/ */
public <T> T readValue(String jsonString, Class<T> objClass) throws IOException { public <T> T readValue(String jsonString, Class<T> objClass) throws IOException {
try { try {
return readValue(new JSONObject(jsonString), objClass); return readValue(new JSONObject(jsonString), objClass);
} }
catch (IOException ioe) { catch (IOException ioe) {
throw ioe; throw ioe;
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new IOException(e); throw new IOException(e);
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T, R> T readValue(JSONObject json, Class<T> objClass) throws IOException { public <T, R> T readValue(JSONObject json, Class<T> objClass) throws IOException {
try { try {
//TODO Iterate through json object values and call the JsonAnySetter method on the unknown ones. //TODO Iterate through json object values and call the JsonAnySetter method on the unknown ones.
T obj = objClass.newInstance(); T obj = objClass.newInstance();
for (Field f : objClass.getFields()) { for (Field f : objClass.getFields()) {
Annotation a = f.getAnnotation(JsonProperty.class); Annotation a = f.getAnnotation(JsonProperty.class);
if (List.class.equals(f.getType()) && (json.optJSONArray(((JsonProperty) a).value()) != null)) { // It's a list. if (List.class.equals(f.getType()) && (json.optJSONArray(((JsonProperty) a).value()) != null)) { // It's a list.
JSONArray jsonArray = json.optJSONArray(((JsonProperty) a).value()); JSONArray jsonArray = json.optJSONArray(((JsonProperty) a).value());
ParameterizedType listType = (ParameterizedType) f.getGenericType(); ParameterizedType listType = (ParameterizedType) f.getGenericType();
Class<?> subObj = (Class<?>) listType.getActualTypeArguments()[0]; Class<?> subObj = (Class<?>) listType.getActualTypeArguments()[0];
List<R> subObjList = ((Class<List<R>>) f.getType()).newInstance(); List<R> subObjList = ((Class<List<R>>) f.getType()).newInstance();
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj)); subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj));
} }
f.set(obj, subObjList); f.set(obj, subObjList);
} }
else if (a != null) { else if (a != null) {
f.set(obj, json.opt(((JsonProperty) a).value())); f.set(obj, json.opt(((JsonProperty) a).value()));
} }
} }
return obj; return obj;
} }
catch (IOException ioe) { catch (IOException ioe) {
throw ioe; throw ioe;
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new IOException(e); throw new IOException(e);
} }
} }
} }
+6 -6
View File
@@ -1,6 +1,6 @@
Jackson Library Replacement Jackson Library Replacement
=========================== ===========================
These files are provided by Darren Beattie as an example of how to replace the Jackson libraries with native libraries inside Android. These files are provided by Darren Beattie as an example of how to replace the Jackson libraries with native libraries inside Android.
They are provided without warrantee and if you modify them or find them useful, please let me know. They are provided without warrantee and if you modify them or find them useful, please let me know.
+648 -648
View File
File diff suppressed because it is too large Load Diff
+18 -1
View File
@@ -8,9 +8,26 @@ This API uses the [TheMovieDB.org API](http://api.themoviedb.org/)
Originally written for use by Yet Another Movie Jukebox [(YAMJ)](http://code.google.com/p/moviejukebox/) Originally written for use by Yet Another Movie Jukebox [(YAMJ)](http://code.google.com/p/moviejukebox/)
But anyone can use it for other projects as well. But anyone can use it for other projects as well.
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=Omertron&url=https://github.com/Omertron/api-themoviedb&title=TheMovieDB API&language=&tags=github&category=software)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Omertron/api-themoviedb/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
***
TMDB TV Support
===============
TheMovieDb has recently added TV shows to their site.
I am working on an update to this API to support that, but it will require a re-write of the API to support the new models and ensure that it is simple to understand.
Therefore TV support will be added to *v4.0* of the API, major version change because of the large change to the API. I will release a stable version of 3.9 in the next week before releaseing 4.0 SNAPSHOT.
If you are interested in the current level of TV support checkout the `tv` branch where all the changes are being done.
*** ***
### TheMovieDB.org ### TheMovieDB.org
This is an excellent open database for movie and film content. This is an excellent open database for movie and film content.
I *strongly* encourage you to check it out and contribute to keep it growing. I *strongly* encourage you to check it out and contribute to keep it growing.
+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.8</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>
@@ -1,87 +1,87 @@
/* /*
* 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; package com.omertron.themoviedbapi;
public class MovieDbException extends Exception { public class MovieDbException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public enum MovieDbExceptionType { public enum MovieDbExceptionType {
/* /*
* Unknown error occured * Unknown error occured
*/ */
UNKNOWN_CAUSE, UNKNOWN_CAUSE,
/* /*
* URL is invalid * URL is invalid
*/ */
INVALID_URL, INVALID_URL,
/* /*
* Page not found * Page not found
*/ */
HTTP_404_ERROR, HTTP_404_ERROR,
/* /*
* The movie id was not found * The movie id was not found
*/ */
MOVIE_ID_NOT_FOUND, MOVIE_ID_NOT_FOUND,
/* /*
* Mapping failed from target to internal onbjects * Mapping failed from target to internal onbjects
*/ */
MAPPING_FAILED, MAPPING_FAILED,
/* /*
* Error connecting to the service * Error connecting to the service
*/ */
CONNECTION_ERROR, CONNECTION_ERROR,
/* /*
* Image was invalid * Image was invalid
*/ */
INVALID_IMAGE, INVALID_IMAGE,
/* /*
* Autorisation rejected * Autorisation rejected
*/ */
AUTHORISATION_FAILURE, AUTHORISATION_FAILURE,
/* /*
* Service Unavailable, usually temporary * Service Unavailable, usually temporary
*/ */
HTTP_503_ERROR; HTTP_503_ERROR;
} }
private final MovieDbExceptionType exceptionType; private final MovieDbExceptionType exceptionType;
private final String response; private final String response;
public MovieDbException(final MovieDbExceptionType exceptionType, final String response) { public MovieDbException(final MovieDbExceptionType exceptionType, final String response) {
super(); super();
this.exceptionType = exceptionType; this.exceptionType = exceptionType;
this.response = response; this.response = response;
} }
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final Throwable cause) { public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final Throwable cause) {
super(cause); super(cause);
this.exceptionType = exceptionType; this.exceptionType = exceptionType;
this.response = response; this.response = response;
} }
public MovieDbExceptionType getExceptionType() { public MovieDbExceptionType getExceptionType() {
return exceptionType; return exceptionType;
} }
public String getResponse() { public String getResponse() {
return response; return response;
} }
} }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,70 @@
/*
* 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;
/**
* Abstract class to handle any unknown properties by outputting a log message
*
* @author stuart.boston
*/
public abstract class AbstractJsonMapping implements Serializable {
private Logger log = null;
/**
* Return the current logger.
*
* @return
*/
private Logger getLogger() {
if (log == null) {
log = LoggerFactory.getLogger(this.getClass());
}
return log;
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
protected void handleUnknown(String key, Object value) {
StringBuilder unknown = new StringBuilder(this.getClass().getSimpleName());
unknown.append(": Unknown property='").append(key);
unknown.append("' value='").append(value).append("'");
getLogger().trace(unknown.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -0,0 +1,86 @@
/*
* 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;
@JsonProperty("iso_639_1")
private String language;
@JsonProperty("iso_3166_1")
private String country;
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;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}
@@ -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,164 @@
/* /*
* 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 @JsonProperty("aspect_ratio")
*/ private float aspectRatio;
public class Artwork implements Serializable { @JsonProperty("file_path")
private String filePath;
private static final long serialVersionUID = 1L; @JsonProperty("height")
private int height;
/* @JsonProperty("iso_639_1")
* Logger private String language;
*/ @JsonProperty("width")
private static final Logger LOG = LoggerFactory.getLogger(Artwork.class); private int width;
/* @JsonProperty("vote_average")
* Properties private float voteAverage;
*/ @JsonProperty("vote_count")
@JsonProperty("aspect_ratio") private int voteCount;
private float aspectRatio; @JsonProperty("flag")
@JsonProperty("file_path") private String flag;
private String filePath; private ArtworkType artworkType = ArtworkType.POSTER;
@JsonProperty("height")
private int height; public ArtworkType getArtworkType() {
@JsonProperty("iso_639_1") return artworkType;
private String language; }
@JsonProperty("width")
private int width; public float getAspectRatio() {
@JsonProperty("vote_average") return aspectRatio;
private float voteAverage; }
@JsonProperty("vote_count")
private int voteCount; public String getFilePath() {
@JsonProperty("flag") return filePath;
private String flag; }
private ArtworkType artworkType = ArtworkType.POSTER;
public int getHeight() {
// <editor-fold defaultstate="collapsed" desc="Getter methods"> return height;
public ArtworkType getArtworkType() { }
return artworkType;
} public String getLanguage() {
return language;
public float getAspectRatio() { }
return aspectRatio;
} public int getWidth() {
return width;
public String getFilePath() { }
return filePath;
} public float getVoteAverage() {
return voteAverage;
public int getHeight() { }
return height;
} public int getVoteCount() {
return voteCount;
public String getLanguage() { }
return language;
} public String getFlag() {
return flag;
public int getWidth() { }
return width;
} public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType;
public float getVoteAverage() { }
return voteAverage;
} public void setAspectRatio(float aspectRatio) {
this.aspectRatio = aspectRatio;
public int getVoteCount() { }
return voteCount;
} public void setFilePath(String filePath) {
this.filePath = filePath;
public String getFlag() { }
return flag;
} public void setHeight(int height) {
this.height = height;
// </editor-fold> }
// <editor-fold defaultstate="collapsed" desc="Setter methods"> public void setLanguage(String language) {
public void setArtworkType(ArtworkType artworkType) { this.language = language;
this.artworkType = artworkType; }
}
public void setWidth(int width) {
public void setAspectRatio(float aspectRatio) { this.width = width;
this.aspectRatio = aspectRatio; }
}
public void setVoteAverage(float voteAverage) {
public void setFilePath(String filePath) { this.voteAverage = voteAverage;
this.filePath = filePath; }
}
public void setVoteCount(int voteCount) {
public void setHeight(int height) { this.voteCount = voteCount;
this.height = height; }
}
public void setFlag(String flag) {
public void setLanguage(String language) { this.flag = flag;
this.language = language; }
}
@Override
public void setWidth(int width) { public boolean equals(Object obj) {
this.width = width; if (obj == null) {
} return false;
}
public void setVoteAverage(float voteAverage) { if (getClass() != obj.getClass()) {
this.voteAverage = voteAverage; return false;
} }
final Artwork other = (Artwork) obj;
public void setVoteCount(int voteCount) { if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) {
this.voteCount = voteCount; return false;
} }
if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) {
public void setFlag(String flag) { return false;
this.flag = flag; }
} if (this.height != other.height) {
return false;
// </editor-fold> }
if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) {
/** return false;
* Handle unknown properties and print a message }
* if (this.width != other.width) {
* @param key return false;
* @param value }
*/ if (this.artworkType != other.artworkType) {
@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 = 3;
@Override hash = 71 * hash + Float.floatToIntBits(this.aspectRatio);
public boolean equals(Object obj) { hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0);
if (obj == null) { hash = 71 * hash + this.height;
return false; hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0);
} hash = 71 * hash + this.width;
if (getClass() != obj.getClass()) { hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
return false; return hash;
} }
final Artwork other = (Artwork) obj; }
if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) {
return false;
}
if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) {
return false;
}
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,30 +1,30 @@
/* /*
* 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;
/** /**
* ArtworkType enum List of the artwork types that are available * ArtworkType enum List of the artwork types that are available
*/ */
public enum ArtworkType { public enum ArtworkType {
POSTER, // Poster artwork POSTER, // Poster artwork
BACKDROP, // Fanart/backdrop BACKDROP, // Fanart/backdrop
PROFILE // Person image PROFILE // Person image
} }
@@ -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 {
@@ -17,7 +16,7 @@ public class ChangeKeyItem {
private String key; private String key;
@JsonProperty("items") @JsonProperty("items")
private List<ChangedItem> changedItems = new ArrayList<ChangedItem>(); private List<ChangedItem> changedItems = new ArrayList<ChangedItem>();
private Map<String, Object> newItems = new HashMap<String, Object>(); private final Map<String, Object> newItems = new HashMap<String, Object>();
public String getKey() { public String getKey() {
return key; return key;
@@ -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")
@@ -21,7 +20,7 @@ public class ChangedItem {
private String language; private String language;
@JsonProperty("value") @JsonProperty("value")
private Object value; private Object value;
private Map<String, Object> newItems = new HashMap<String, Object>(); private final Map<String, Object> newItems = new HashMap<String, Object>();
public String getId() { public String getId() {
return id; return 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);
}
} }
@@ -0,0 +1,48 @@
/*
* 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;
public class ChangedMovie extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private String id;
@JsonProperty("adult")
private boolean adult;
public String getId() {
return id;
}
public boolean isAdult() {
return adult;
}
public void setId(String id) {
this.id = id;
}
public void setAdult(boolean adult) {
this.adult = adult;
}
}
@@ -1,172 +1,139 @@
/* /*
* 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; public String getBackdropPath() {
@JsonProperty("name") return backdropPath;
private String name; }
@JsonProperty("poster_path")
private String posterPath; public int getId() {
@JsonProperty("backdrop_path") return id;
private String backdropPath; }
@JsonProperty("release_date")
private String releaseDate; public String getPosterPath() {
return posterPath;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getBackdropPath() {
return backdropPath; public String getReleaseDate() {
} return releaseDate;
}
public int getId() {
return id; public String getTitle() {
} if (StringUtils.isBlank(title)) {
return name;
public String getPosterPath() { }
return posterPath; return title;
} }
public String getReleaseDate() { public String getName() {
return releaseDate; if (StringUtils.isBlank(name)) {
} return title;
}
public String getTitle() { return name;
if (StringUtils.isBlank(title)) { }
return name;
} public void setBackdropPath(String backdropPath) {
return title; this.backdropPath = backdropPath;
} }
public String getName() { public void setId(int id) {
if (StringUtils.isBlank(name)) { this.id = id;
return title; }
}
return name; public void setPosterPath(String posterPath) {
} this.posterPath = posterPath;
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public void setReleaseDate(String releaseDate) {
public void setBackdropPath(String backdropPath) { this.releaseDate = releaseDate;
this.backdropPath = backdropPath; }
}
public void setTitle(String title) {
public void setId(int id) { this.title = title;
this.id = id; }
}
public void setName(String name) {
public void setPosterPath(String posterPath) { this.name = name;
this.posterPath = posterPath; }
}
@Override
public void setReleaseDate(String releaseDate) { public boolean equals(Object obj) {
this.releaseDate = releaseDate; if (obj == null) {
} return false;
}
public void setTitle(String title) { if (getClass() != obj.getClass()) {
this.title = title; return false;
} }
final Collection other = (Collection) obj;
public void setName(String name) { if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) {
this.name = name; 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)) {
* return false;
* @param key }
* @param value if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
*/ return false;
@JsonAnySetter }
public void handleUnknown(String key, Object value) { return true;
StringBuilder sb = new StringBuilder(); }
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'"); @Override
LOG.trace(sb.toString()); public int hashCode() {
} int hash = 7;
hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
@Override hash = 19 * hash + this.id;
public boolean equals(Object obj) { hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
if (obj == null) { hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
return false; hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
} hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
if (getClass() != obj.getClass()) { return hash;
return false; }
} }
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
*/ */
@@ -56,7 +47,6 @@ public class CollectionInfo implements Serializable {
@JsonProperty("parts") @JsonProperty("parts")
private List<Collection> parts = new ArrayList<Collection>(); private List<Collection> parts = new ArrayList<Collection>();
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() { public String getBackdropPath() {
return backdropPath; return backdropPath;
} }
@@ -80,9 +70,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 +94,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,112 @@
/* /*
* 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; public int getCompanyId() {
@JsonProperty("homepage") return companyId;
private String homepage = DEFAULT_STRING; }
@JsonProperty("logo_path")
private String logoPath = DEFAULT_STRING; public String getDescription() {
@JsonProperty("parent_company") return description;
private String parentCompany = DEFAULT_STRING; }
//<editor-fold defaultstate="collapsed" desc="Getter Methods"> public String getHeadquarters() {
public int getCompanyId() { return headquarters;
return companyId; }
}
public String getHomepage() {
public String getDescription() { return homepage;
return description; }
}
public String getLogoPath() {
public String getHeadquarters() { return logoPath;
return headquarters; }
}
public String getName() {
public String getHomepage() { return name;
return homepage; }
}
public Company getParentCompany() {
public String getLogoPath() { return parentCompany;
return logoPath; }
}
public void setCompanyId(int companyId) {
public String getName() { this.companyId = companyId;
return name; }
}
public void setDescription(String description) {
public String getParentCompany() { this.description = description;
return parentCompany; }
}
//</editor-fold> public void setHeadquarters(String headquarters) {
this.headquarters = headquarters;
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> }
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();
parent.setCompanyId(companyId);
public void setName(String name) { parent.setName(name);
this.name = 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,21 +19,23 @@
*/ */
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
*/ */
public class Discover { public class Discover {
private Map<String, String> params = new HashMap<String, String>(); private final Map<String, String> params = new HashMap<String, String>();
private static final String PARAM_PRIMARY_RELEASE_YEAR = "primary_release_year="; private static final String PARAM_PRIMARY_RELEASE_YEAR = "primary_release_year=";
private static final String PARAM_VOTE_COUNT_GTE = "vote_count.gte="; private static final String PARAM_VOTE_COUNT_GTE = "vote_count.gte=";
private static final String PARAM_VOTE_AVERAGE_GTE = "vote_average.gte="; private static final String PARAM_VOTE_AVERAGE_GTE = "vote_average.gte=";
@@ -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
@@ -62,6 +64,7 @@ public class Discover {
* Minimum value is 1 if included. * Minimum value is 1 if included.
* *
* @param page * @param page
* @return
*/ */
public Discover page(int page) { public Discover page(int page) {
if (page > 0) { if (page > 0) {
@@ -74,6 +77,7 @@ public class Discover {
* ISO 639-1 code * ISO 639-1 code
* *
* @param language * @param language
* @return
*/ */
public Discover language(String language) { public Discover language(String language) {
if (StringUtils.isNotBlank(language)) { if (StringUtils.isNotBlank(language)) {
@@ -92,6 +96,7 @@ public class Discover {
* popularity.asc * popularity.asc
* *
* @param sortBy * @param sortBy
* @return
*/ */
public Discover sortBy(String sortBy) { public Discover sortBy(String sortBy) {
if (StringUtils.isNotBlank(sortBy)) { if (StringUtils.isNotBlank(sortBy)) {
@@ -104,6 +109,7 @@ public class Discover {
* Toggle the inclusion of adult titles * Toggle the inclusion of adult titles
* *
* @param includeAdult * @param includeAdult
* @return
*/ */
public Discover includeAdult(boolean includeAdult) { public Discover includeAdult(boolean includeAdult) {
params.put(PARAM_ADULT, String.valueOf(includeAdult)); params.put(PARAM_ADULT, String.valueOf(includeAdult));
@@ -114,6 +120,7 @@ public class Discover {
* Filter the results release dates to matches that include this value. * Filter the results release dates to matches that include this value.
* *
* @param year * @param year
* @return
*/ */
public Discover year(int year) { public Discover year(int year) {
if (checkYear(year)) { if (checkYear(year)) {
@@ -126,6 +133,7 @@ public class Discover {
* Filter the results so that only the primary release date year has this value * Filter the results so that only the primary release date year has this value
* *
* @param primaryReleaseYear * @param primaryReleaseYear
* @return
*/ */
public Discover primaryReleaseYear(int primaryReleaseYear) { public Discover primaryReleaseYear(int primaryReleaseYear) {
if (checkYear(primaryReleaseYear)) { if (checkYear(primaryReleaseYear)) {
@@ -138,6 +146,7 @@ public class Discover {
* Only include movies that are equal to, or have a vote count higher than this value * Only include movies that are equal to, or have a vote count higher than this value
* *
* @param voteCountGte * @param voteCountGte
* @return
*/ */
public Discover voteCountGte(int voteCountGte) { public Discover voteCountGte(int voteCountGte) {
if (voteCountGte > 0) { if (voteCountGte > 0) {
@@ -150,6 +159,7 @@ public class Discover {
* Only include movies that are equal to, or have a higher average rating than this value * Only include movies that are equal to, or have a higher average rating than this value
* *
* @param voteAverageGte * @param voteAverageGte
* @return
*/ */
public Discover voteAverageGte(float voteAverageGte) { public Discover voteAverageGte(float voteAverageGte) {
if (voteAverageGte > 0) { if (voteAverageGte > 0) {
@@ -160,14 +170,15 @@ 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
* @return
*/ */
public Discover withGenres(String withGenres) { public Discover withGenres(String withGenres) {
if (StringUtils.isNotBlank(withGenres)) { if (StringUtils.isNotBlank(withGenres)) {
@@ -178,10 +189,11 @@ 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
* @return
*/ */
public Discover releaseDateGte(String releaseDateGte) { public Discover releaseDateGte(String releaseDateGte) {
if (StringUtils.isNotBlank(releaseDateGte)) { if (StringUtils.isNotBlank(releaseDateGte)) {
@@ -192,10 +204,11 @@ 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
* @return
*/ */
public Discover releaseDateLte(String releaseDateLte) { public Discover releaseDateLte(String releaseDateLte) {
if (StringUtils.isNotBlank(releaseDateLte)) { if (StringUtils.isNotBlank(releaseDateLte)) {
@@ -206,12 +219,13 @@ 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
* @return
*/ */
public Discover certificationCountry(String certificationCountry) { public Discover certificationCountry(String certificationCountry) {
if (StringUtils.isNotBlank(certificationCountry)) { if (StringUtils.isNotBlank(certificationCountry)) {
@@ -222,10 +236,11 @@ 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
* @return
*/ */
public Discover certificationLte(String certificationLte) { public Discover certificationLte(String certificationLte) {
if (StringUtils.isNotBlank(certificationLte)) { if (StringUtils.isNotBlank(certificationLte)) {
@@ -236,12 +251,13 @@ 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
* @return
*/ */
public Discover withCompanies(String withCompanies) { public Discover withCompanies(String withCompanies) {
if (StringUtils.isNotBlank(withCompanies)) { if (StringUtils.isNotBlank(withCompanies)) {
@@ -1,115 +1,81 @@
/* /*
* 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 public int getId() {
*/ return id;
private static final Logger LOG = LoggerFactory.getLogger(Genre.class); }
/*
* Properties public String getName() {
*/ return name;
@JsonProperty("id") }
private int id;
@JsonProperty("name") public void setId(int id) {
private String name; this.id = id;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { public void setName(String name) {
return id; this.name = name;
} }
public String getName() { @Override
return name; public boolean equals(Object obj) {
} if (obj == null) {
//</editor-fold> return false;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods"> if (getClass() != obj.getClass()) {
public void setId(int id) { return false;
this.id = id; }
} final Genre other = (Genre) obj;
if (this.id != other.id) {
public void setName(String name) { return false;
this.name = name; }
} if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
//</editor-fold> return false;
}
/** return true;
* Handle unknown properties and print a message }
*
* @param key @Override
* @param value public int hashCode() {
*/ int hash = 5;
@JsonAnySetter hash = 53 * hash + this.id;
public void handleUnknown(String key, Object value) { hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
StringBuilder sb = new StringBuilder(); return hash;
sb.append("Unknown property: '").append(key); }
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,26 +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 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 { import java.util.List;
public class JobDepartment extends AbstractJsonMapping {
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;
@JsonProperty("job_list") @JsonProperty("job_list")
private List<String> jobs; private List<String> jobs;
//<editor-fold defaultstate="collapsed" desc="Getters">
public String getDepartment() { public String getDepartment() {
return department; return department;
} }
@@ -46,9 +39,7 @@ public class JobDepartment {
public List<String> getJobs() { public List<String> getJobs() {
return jobs; return jobs;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setters">
public void setDepartment(String department) { public void setDepartment(String department) {
this.department = department; this.department = department;
} }
@@ -56,24 +47,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,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("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 public int getId() {
*/ return id;
private static final Logger LOG = LoggerFactory.getLogger(Keyword.class); }
/*
* Properties public String getName() {
*/ return name;
@JsonProperty("id") }
private int id;
@JsonProperty("name") public void setId(int id) {
private String name; this.id = id;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { public void setName(String name) {
return id; this.name = name;
} }
public String getName() { @Override
return name; public boolean equals(Object obj) {
} if (obj == null) {
//</editor-fold> return false;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods"> if (getClass() != obj.getClass()) {
public void setId(int id) { return false;
this.id = id; }
} final Keyword other = (Keyword) obj;
if (this.id != other.id) {
public void setName(String name) { return false;
this.name = name; }
} if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
//</editor-fold> return false;
}
/** return true;
* Handle unknown properties and print a message }
*
* @param key @Override
* @param value public int hashCode() {
*/ int hash = 3;
@JsonAnySetter hash = 83 * hash + this.id;
public void handleUnknown(String key, Object value) { hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
StringBuilder sb = new StringBuilder(); return hash;
sb.append("Unknown property: '").append(key); }
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,138 @@
/* /*
* 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") public static long getSerialVersionUID() {
private String title; return serialVersionUID;
@JsonProperty("vote_average") }
private float voteAverage;
@JsonProperty("vote_count") public String getBackdropPath() {
private double voteCount; return backdropPath;
@JsonProperty("adult") }
private boolean adult;
@JsonProperty("popularity") public String getId() {
private float popularity; return id;
}
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public static long getSerialVersionUID() { public String getOriginalTitle() {
return serialVersionUID; return originalTitle;
} }
public String getBackdropPath() { public String getReleaseDate() {
return backdropPath; return releaseDate;
} }
public String getId() { public String getPosterPath() {
return id; return posterPath;
} }
public String getOriginalTitle() { public String getTitle() {
return originalTitle; return title;
} }
public String getReleaseDate() { public float getVoteAverage() {
return releaseDate; return voteAverage;
} }
public String getPosterPath() { public double getVoteCount() {
return posterPath; return voteCount;
} }
public String getTitle() { public boolean isAdult() {
return title; return adult;
} }
public float getVoteAverage() { public float getPopularity() {
return voteAverage; return popularity;
} }
public double getVoteCount() { public void setBackdropPath(String backdropPath) {
return voteCount; this.backdropPath = backdropPath;
} }
public boolean isAdult() { public void setId(String id) {
return adult; this.id = id;
} }
public float getPopularity() { public void setOriginalTitle(String originalTitle) {
return popularity; this.originalTitle = originalTitle;
} }
// </editor-fold>
public void setReleaseDate(String releaseDate) {
// <editor-fold defaultstate="collapsed" desc="Setter methods"> this.releaseDate = releaseDate;
public void setBackdropPath(String backdropPath) { }
this.backdropPath = backdropPath;
} public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
public void setId(String id) { }
this.id = id;
} public void setTitle(String title) {
this.title = title;
public void setOriginalTitle(String originalTitle) { }
this.originalTitle = originalTitle;
} public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage;
public void setReleaseDate(String releaseDate) { }
this.releaseDate = releaseDate;
} public void setVoteCount(double voteCount) {
this.voteCount = voteCount;
public void setPosterPath(String posterPath) { }
this.posterPath = posterPath;
} public void setAdult(boolean adult) {
this.adult = adult;
public void setTitle(String title) { }
this.title = title;
} public void setPopularity(float popularity) {
this.popularity = popularity;
public void setVoteAverage(float voteAverage) { }
this.voteAverage = voteAverage; }
}
public void setVoteCount(double voteCount) {
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,81 @@
/* /*
* 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 public String getIsoCode() {
*/ return isoCode;
private static final Logger LOG = LoggerFactory.getLogger(Language.class); }
/*
* Properties public String getName() {
*/ return name;
@JsonProperty("iso_639_1") }
private String isoCode;
@JsonProperty("name") public void setIsoCode(String isoCode) {
private String name; this.isoCode = isoCode;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getIsoCode() { public void setName(String name) {
return isoCode; this.name = name;
} }
public String getName() { @Override
return name; public boolean equals(Object obj) {
} if (obj == null) {
//</editor-fold> return false;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods"> if (getClass() != obj.getClass()) {
public void setIsoCode(String isoCode) { return false;
this.isoCode = isoCode; }
} final Language other = (Language) obj;
if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
public void setName(String name) { return false;
this.name = name; }
} if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
//</editor-fold> return false;
}
/** return true;
* Handle unknown properties and print a message }
*
* @param key @Override
* @param value public int hashCode() {
*/ int hash = 7;
@JsonAnySetter hash = 71 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
public void handleUnknown(String key, Object value) { hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
StringBuilder sb = new StringBuilder(); return hash;
sb.append("Unknown property: '").append(key); }
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,40 +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
*/
@JsonProperty("backdrop_path") @JsonProperty("backdrop_path")
private String backdropPath; private String backdropPath;
@JsonProperty("id") @JsonProperty("id")
@@ -93,6 +72,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 +194,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 +293,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 +342,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 +384,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 +416,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,144 @@
/* /*
* 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 @JsonProperty("id")
*/ private String id;
public class MovieDbList { @JsonProperty("created_by")
/* private String createdBy;
* Logger @JsonProperty("description")
*/ private String description;
@JsonProperty("favorite_count")
private static final Logger LOG = LoggerFactory.getLogger(MovieDbList.class); private int favoriteCount;
/* @JsonProperty("items")
* Properties private List<MovieDb> items = Collections.EMPTY_LIST;
*/ @JsonProperty("item_count")
@JsonProperty("id") private int itemCount;
private String id; @JsonProperty("iso_639_1")
@JsonProperty("created_by") private String language;
private String createdBy; @JsonProperty("name")
@JsonProperty("description") private String name;
private String description; @JsonProperty("poster_path")
@JsonProperty("favorite_count") private String posterPath;
private int favoriteCount; @JsonProperty("status_code")
@JsonProperty("items") private String statusCode;
private List<MovieDb> items = Collections.EMPTY_LIST; @JsonProperty("status_message")
@JsonProperty("item_count") private String statusMessage;
private int itemCount;
@JsonProperty("iso_639_1") public String getId() {
private String language; return id;
@JsonProperty("name") }
private String name;
@JsonProperty("poster_path") public String getCreatedBy() {
private String posterPath; return createdBy;
}
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() { public String getDescription() {
return id; return description;
} }
public String getCreatedBy() { public int getFavoriteCount() {
return createdBy; return favoriteCount;
} }
public String getDescription() { public List<MovieDb> getItems() {
return description; return items;
} }
public int getFavoriteCount() { public int getItemCount() {
return favoriteCount; return itemCount;
} }
public List<MovieDb> getItems() { public String getLanguage() {
return items; return language;
} }
public int getItemCount() { public String getName() {
return itemCount; return name;
} }
public String getLanguage() { public String getPosterPath() {
return language; return posterPath;
} }
public String getName() { public String getStatusCode() {
return name; return statusCode;
} }
public String getPosterPath() { public String getStatusMessage() {
return posterPath; return statusMessage;
} }
//</editor-fold>
public void setId(String id) {
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> this.id = id;
public void setId(String id) { }
this.id = id;
} public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
public void setCreatedBy(String createdBy) { }
this.createdBy = createdBy;
} public void setDescription(String description) {
this.description = description;
public void setDescription(String description) { }
this.description = description;
} public void setFavoriteCount(int favoriteCount) {
this.favoriteCount = favoriteCount;
public void setFavoriteCount(int favoriteCount) { }
this.favoriteCount = favoriteCount;
} public void setItems(List<MovieDb> items) {
this.items = items;
public void setItems(List<MovieDb> items) { }
this.items = items;
} public void setItemCount(int itemCount) {
this.itemCount = itemCount;
public void setItemCount(int itemCount) { }
this.itemCount = itemCount;
} public void setLanguage(String language) {
this.language = language;
public void setLanguage(String language) { }
this.language = language;
} public void setName(String name) {
this.name = name;
public void setName(String name) { }
this.name = name;
} public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
public void setPosterPath(String posterPath) { }
this.posterPath = posterPath;
} public void setStatusCode(String statusCode) {
//</editor-fold> this.statusCode = statusCode;
}
/**
* Handle unknown properties and print a message public void setStatusMessage(String statusMessage) {
* this.statusMessage = statusMessage;
* @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);
}
}
@@ -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,111 @@
/* /*
* 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;
/**
* @JsonProperty("description")
* @author Stuart private String description;
*/ @JsonProperty("favorite_count")
public class MovieList implements Serializable { private int favoriteCount;
@JsonProperty("id")
private static final long serialVersionUID = 1L; private String id;
@JsonProperty("item_count")
/* private int itemCount;
* Logger @JsonProperty("iso_639_1")
*/ private String language;
private static final Logger LOG = LoggerFactory.getLogger(MovieList.class); @JsonProperty("name")
/* private String name;
* Properties @JsonProperty("poster_path")
*/ private String posterPath;
@JsonProperty("description") @JsonProperty("list_type")
private String description; private String listType;
@JsonProperty("favorite_count")
private int favoriteCount; public String getDescription() {
@JsonProperty("id") return description;
private String id; }
@JsonProperty("item_count")
private int itemCount; public int getFavoriteCount() {
@JsonProperty("iso_639_1") return favoriteCount;
private String language; }
@JsonProperty("name")
private String name; public String getId() {
@JsonProperty("poster_path") return id;
private String posterPath; }
@JsonProperty("list_type")
private String listType; public int getItemCount() {
return itemCount;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getDescription() {
return description; public String getLanguage() {
} return language;
}
public int getFavoriteCount() {
return favoriteCount; public String getName() {
} return name;
}
public String getId() {
return id; public String getPosterPath() {
} return posterPath;
}
public int getItemCount() {
return itemCount; public String getListType() {
} return listType;
}
public String getLanguage() {
return language; public void setDescription(String description) {
} this.description = description;
}
public String getName() {
return name; public void setFavoriteCount(int favoriteCount) {
} this.favoriteCount = favoriteCount;
}
public String getPosterPath() {
return posterPath; public void setId(String id) {
} this.id = id;
}
public String getListType() {
return listType; public void setItemCount(int itemCount) {
} this.itemCount = itemCount;
// </editor-fold> }
// <editor-fold defaultstate="collapsed" desc="Setter methods"> public void setLanguage(String language) {
public void setDescription(String description) { this.language = language;
this.description = description; }
}
public void setName(String name) {
public void setFavoriteCount(int favoriteCount) { this.name = name;
this.favoriteCount = favoriteCount; }
}
public void setPosterPath(String posterPath) {
public void setId(String id) { this.posterPath = posterPath;
this.id = id; }
}
public void setListType(String listType) {
public void setItemCount(int itemCount) { this.listType = listType;
this.itemCount = itemCount; }
} }
public void setLanguage(String language) {
this.language = language;
}
public void setName(String name) {
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,295 @@
/* /*
* 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; public String getCharacter() {
this.id = id; return character;
this.name = name; }
this.profilePath = profilePath;
this.character = character; public String getDepartment() {
this.order = order; return department;
this.department = CAST_DEPARTMENT; }
this.job = CAST_JOB;
} public int getId() {
return id;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> }
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; public void setCharacter(String character) {
} this.character = character;
}
public String getImdbId() {
return imdbId; public void setDepartment(String department) {
} this.department = department;
}
public float getPopularity() {
return popularity; public void setId(int id) {
} this.id = id;
// </editor-fold> }
// <editor-fold defaultstate="collapsed" desc="Setter methods"> public void setJob(String job) {
public void setCharacter(String character) { this.job = StringUtils.trimToEmpty(job);
this.character = character; }
}
public void setName(String name) {
public void setDepartment(String department) { this.name = StringUtils.trimToEmpty(name);
this.department = department; }
}
public void setOrder(int order) {
public void setId(int id) { this.order = order;
this.id = id; }
}
public void setPersonType(PersonType personType) {
public void setJob(String job) { this.personType = personType;
this.job = job; }
}
public void setProfilePath(String profilePath) {
public void setName(String name) { this.profilePath = StringUtils.trimToEmpty(profilePath);
this.name = name; }
}
public void setAdult(boolean adult) {
public void setOrder(int order) { this.adult = adult;
this.order = order; }
}
public void setAka(List<String> aka) {
public void setPersonType(PersonType personType) { this.aka = aka;
this.personType = personType; }
}
public void setBiography(String biography) {
public void setProfilePath(String profilePath) { this.biography = StringUtils.trimToEmpty(biography);
this.profilePath = profilePath; }
}
public void setBirthday(String birthday) {
public void setAdult(boolean adult) { this.birthday = StringUtils.trimToEmpty(birthday);
this.adult = adult; }
}
public void setBirthplace(String birthplace) {
public void setAka(List<String> aka) { this.birthplace = StringUtils.trimToEmpty(birthplace);
this.aka = aka; }
}
public void setDeathday(String deathday) {
public void setBiography(String biography) { this.deathday = StringUtils.trimToEmpty(deathday);
this.biography = biography; }
}
public void setHomepage(String homepage) {
public void setBirthday(String birthday) { this.homepage = StringUtils.trimToEmpty(homepage);
this.birthday = birthday; }
}
public void setImdbId(String imdbId) {
public void setBirthplace(String birthplace) { this.imdbId = StringUtils.trimToEmpty(imdbId);
this.birthplace = birthplace; }
}
public void setPopularity(float popularity) {
public void setDeathday(String deathday) { this.popularity = popularity;
this.deathday = deathday; }
}
@Override
public void setHomepage(String homepage) { public boolean equals(Object obj) {
this.homepage = homepage; if (obj == null) {
} return false;
}
public void setImdbId(String imdbId) { if (getClass() != obj.getClass()) {
this.imdbId = imdbId; return false;
} }
final Person other = (Person) obj;
public void setPopularity(float popularity) { if (this.id != other.id) {
this.popularity = popularity; 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 if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) {
* return false;
* @param key }
* @param value if (this.personType != other.personType) {
*/ return false;
@JsonAnySetter }
public void handleUnknown(String key, Object value) { if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
StringBuilder sb = new StringBuilder(); return false;
sb.append("Unknown property: '").append(key); }
sb.append("' value: '").append(value).append("'"); if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
LOG.trace(sb.toString()); return false;
} }
if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) {
@Override return false;
public boolean equals(Object obj) { }
if (obj == null) { return true;
return false; }
}
if (getClass() != obj.getClass()) { @Override
return false; public int hashCode() {
} int hash = 3;
final Person other = (Person) obj; hash = 37 * hash + this.id;
if (this.id != other.id) { hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
return false; hash = 37 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
} hash = 37 * hash + (this.personType != null ? this.personType.hashCode() : 0);
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { hash = 37 * hash + (this.department != null ? this.department.hashCode() : 0);
return false; hash = 37 * hash + (this.job != null ? this.job.hashCode() : 0);
} hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { return hash;
return false; }
} }
if (this.personType != other.personType) {
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.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,133 @@
/* /*
* 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; public String getCharacter() {
@JsonProperty("name") return character;
private String name; }
@JsonProperty("order")
private int order; public int getId() {
@JsonProperty("profile_path") return id;
private String profilePath; }
@JsonProperty("cast_id")
private int castId; public String getName() {
return name;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
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>
public void setOrder(int order) {
//<editor-fold defaultstate="collapsed" desc="Setter methods"> this.order = order;
public void setCharacter(String character) { }
this.character = character;
} public void setProfilePath(String profilePath) {
this.profilePath = StringUtils.trimToEmpty(profilePath);
public void setId(int id) { }
this.id = id;
} public void setCastId(int castId) {
this.castId = castId;
public void setName(String name) { }
this.name = name;
} @Override
public boolean equals(Object obj) {
public void setOrder(int order) { if (obj == null) {
this.order = order; return false;
} }
if (getClass() != obj.getClass()) {
public void setProfilePath(String profilePath) { return false;
this.profilePath = profilePath; }
} final PersonCast other = (PersonCast) obj;
if (this.id != other.id) {
public void setCastId(int castId) { return false;
this.castId = castId; }
} if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) {
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 }
* if (this.order != other.order) {
* @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(); 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 = 41 * hash + this.id;
public boolean equals(Object obj) { hash = 41 * hash + (this.character != null ? this.character.hashCode() : 0);
if (obj == null) { hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0);
return false; hash = 41 * hash + this.order;
} hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
if (getClass() != obj.getClass()) { return hash;
return false; }
} }
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,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.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; public String getCharacter() {
@JsonProperty("title") return character;
private String movieTitle = DEFAULT_STRING; }
@JsonProperty("department")
private String department = DEFAULT_STRING; public String getDepartment() {
@JsonProperty("job") return department;
private String job = DEFAULT_STRING; }
@JsonProperty("adult")
private String adult = DEFAULT_STRING; public String getJob() {
private PersonType personType = PersonType.PERSON; return job;
}
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getCharacter() { public int getMovieId() {
return character; return movieId;
} }
public String getDepartment() { public String getMovieOriginalTitle() {
return department; return movieOriginalTitle;
} }
public String getJob() { public String getMovieTitle() {
return job; return movieTitle;
} }
public int getMovieId() { public PersonType getPersonType() {
return movieId; return personType;
} }
public String getMovieOriginalTitle() { public String getPosterPath() {
return movieOriginalTitle; return posterPath;
} }
public String getMovieTitle() { public String getReleaseDate() {
return movieTitle; return releaseDate;
} }
public PersonType getPersonType() { public String getAdult() {
return personType; return adult;
} }
public String getPosterPath() { public void setCharacter(String character) {
return posterPath; this.character = StringUtils.trimToEmpty(character);
} }
public String getReleaseDate() { public void setDepartment(String department) {
return releaseDate; this.department = StringUtils.trimToEmpty(department);
} }
public String getAdult() { public void setJob(String job) {
return adult; this.job = StringUtils.trimToEmpty(job);
} }
//</editor-fold>
public void setMovieId(int movieId) {
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> this.movieId = movieId;
public void setCharacter(String character) { }
this.character = character;
} public void setMovieOriginalTitle(String movieOriginalTitle) {
this.movieOriginalTitle = StringUtils.trimToEmpty(movieOriginalTitle);
public void setDepartment(String department) { }
this.department = department;
} public void setMovieTitle(String movieTitle) {
this.movieTitle = StringUtils.trimToEmpty(movieTitle);
public void setJob(String job) { }
this.job = job;
} public void setPersonType(PersonType personType) {
this.personType = personType;
public void setMovieId(int movieId) { }
this.movieId = movieId;
} public void setPosterPath(String posterPath) {
this.posterPath = StringUtils.trimToEmpty(posterPath);
public void setMovieOriginalTitle(String movieOriginalTitle) { }
this.movieOriginalTitle = movieOriginalTitle;
} public void setReleaseDate(String releaseDate) {
this.releaseDate = StringUtils.trimToEmpty(releaseDate);
public void setMovieTitle(String movieTitle) { }
this.movieTitle = movieTitle;
} public void setAdult(String adult) {
this.adult = StringUtils.trimToEmpty(adult);
public void setPersonType(PersonType personType) { }
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,120 @@
/* /*
* 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; public String getDepartment() {
@JsonProperty("department") return department;
private String department; }
@JsonProperty("job")
private String job; public int getId() {
@JsonProperty("name") return id;
private String name; }
@JsonProperty("profile_path")
private String profilePath; public String getJob() {
return job;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
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) {
} this.job = StringUtils.trimToEmpty(job);
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public void setName(String name) {
public void setDepartment(String department) { this.name = StringUtils.trimToEmpty(name);
this.department = department; }
}
public void setProfilePath(String profilePath) {
public void setId(int id) { this.profilePath = StringUtils.trimToEmpty(profilePath);
this.id = id; }
}
@Override
public void setJob(String job) { public boolean equals(Object obj) {
this.job = job; if (obj == null) {
} return false;
}
public void setName(String name) { if (getClass() != obj.getClass()) {
this.name = name; return false;
} }
final PersonCrew other = (PersonCrew) obj;
public void setProfilePath(String profilePath) { if (this.id != other.id) {
this.profilePath = profilePath; 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)) {
* return false;
* @param key }
* @param value if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
*/ return false;
@JsonAnySetter }
public void handleUnknown(String key, Object value) { return true;
StringBuilder sb = new StringBuilder(); }
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'"); @Override
LOG.trace(sb.toString()); public int hashCode() {
} int hash = 7;
hash = 59 * hash + this.id;
@Override hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
public boolean equals(Object obj) { hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
if (obj == null) { hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
return false; hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
} return hash;
if (getClass() != obj.getClass()) { }
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);
}
}
@@ -1,31 +1,30 @@
/* /*
* 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;
/** /**
* * @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,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("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 public int getId() {
*/ return id;
private static final Logger LOG = LoggerFactory.getLogger(ProductionCompany.class); }
/*
* Properties public String getName() {
*/ return name;
@JsonProperty("id") }
private int id;
@JsonProperty("name") public void setId(int id) {
private String name; this.id = id;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { public void setName(String name) {
return id; this.name = name;
} }
public String getName() { @Override
return name; public boolean equals(Object obj) {
} if (obj == null) {
//</editor-fold> return false;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods"> if (getClass() != obj.getClass()) {
public void setId(int id) { return false;
this.id = id; }
} final ProductionCompany other = (ProductionCompany) obj;
if (this.id != other.id) {
public void setName(String name) { return false;
this.name = name; }
} if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
//</editor-fold> return false;
}
/** return true;
* Handle unknown properties and print a message }
*
* @param key @Override
* @param value public int hashCode() {
*/ int hash = 5;
@JsonAnySetter hash = 37 * hash + this.id;
public void handleUnknown(String key, Object value) { hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
StringBuilder sb = new StringBuilder(); return hash;
sb.append("Unknown property: '").append(key); }
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,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("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 public String getIsoCode() {
*/ return isoCode;
private static final Logger LOG = LoggerFactory.getLogger(ProductionCountry.class); }
/*
* Properties public String getName() {
*/ return name;
@JsonProperty("iso_3166_1") }
private String isoCode;
@JsonProperty("name") public void setIsoCode(String isoCode) {
private String name; this.isoCode = isoCode;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getIsoCode() { public void setName(String name) {
return isoCode; this.name = name;
} }
public String getName() { @Override
return name; public boolean equals(Object obj) {
} if (obj == null) {
//</editor-fold> return false;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods"> if (getClass() != obj.getClass()) {
public void setIsoCode(String isoCode) { return false;
this.isoCode = isoCode; }
} final ProductionCountry other = (ProductionCountry) obj;
if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
public void setName(String name) { return false;
this.name = name; }
} if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
//</editor-fold> return false;
}
/** return true;
* Handle unknown properties and print a message }
*
* @param key @Override
* @param value public int hashCode() {
*/ int hash = 7;
@JsonAnySetter hash = 47 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0);
public void handleUnknown(String key, Object value) { hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
StringBuilder sb = new StringBuilder(); return hash;
sb.append("Unknown property: '").append(key); }
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,94 @@
/* /*
* 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); public String getCertification() {
/* return certification;
* Properties }
*/
@JsonProperty("iso_3166_1") public String getCountry() {
private String country; return country;
@JsonProperty("certification") }
private String certification;
@JsonProperty("release_date") public String getReleaseDate() {
private String releaseDate; return releaseDate;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCertification() { public void setCertification(String certification) {
return certification; this.certification = certification;
} }
public String getCountry() { public void setCountry(String country) {
return country; this.country = country;
} }
public String getReleaseDate() { public void setReleaseDate(String releaseDate) {
return releaseDate; this.releaseDate = releaseDate;
} }
//</editor-fold>
@Override
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public boolean equals(Object obj) {
public void setCertification(String certification) { if (obj == null) {
this.certification = certification; return false;
} }
if (getClass() != obj.getClass()) {
public void setCountry(String country) { return false;
this.country = country; }
} final ReleaseInfo other = (ReleaseInfo) obj;
if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) {
public void setReleaseDate(String releaseDate) { return false;
this.releaseDate = releaseDate; }
} if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) {
//</editor-fold> return false;
}
/** if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) {
* 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 = 3;
sb.append("Unknown property: '").append(key); hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0);
sb.append("' value: '").append(value).append("'"); hash = 89 * hash + (this.certification != null ? this.certification.hashCode() : 0);
LOG.trace(sb.toString()); 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
*/ */
@@ -51,7 +40,6 @@ public class Reviews implements Serializable {
@JsonProperty("url") @JsonProperty("url")
private String url; private String url;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getId() { public String getId() {
return id; return id;
} }
@@ -67,9 +55,7 @@ public class Reviews implements Serializable {
public String getUrl() { public String getUrl() {
return url; return url;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
@@ -85,24 +71,4 @@ public class Reviews implements Serializable {
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
// </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,54 @@
/* /*
* 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 public int getStatusCode() {
*/ return statusCode;
private static final Logger LOG = LoggerFactory.getLogger(StatusCode.class); }
/*
* Properties public void setStatusCode(int statusCode) {
*/ this.statusCode = statusCode;
@JsonProperty("status_code") }
private int statusCode;
@JsonProperty("status_message") public String getStatusMessage() {
private String statusMessage; return statusMessage;
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getStatusCode() { public void setStatusMessage(String statusMessage) {
return statusCode; 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,174 @@
/* /*
* 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; public List<String> getBackdropSizes() {
@JsonProperty("poster_sizes") return backdropSizes;
private List<String> posterSizes; }
@JsonProperty("backdrop_sizes")
private List<String> backdropSizes; public String getBaseUrl() {
@JsonProperty("profile_sizes") return baseUrl;
private List<String> profileSizes; }
@JsonProperty("logo_sizes")
private List<String> logoSizes; public List<String> getPosterSizes() {
return posterSizes;
// <editor-fold defaultstate="collapsed" desc="Getter methods">//GEN-BEGIN:getterMethods }
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; public void setBackdropSizes(List<String> backdropSizes) {
} this.backdropSizes = backdropSizes;
}
public List<String> getLogoSizes() {
return logoSizes; public void setBaseUrl(String baseUrl) {
} this.baseUrl = baseUrl;
}
public String getSecureBaseUrl() {
return secureBaseUrl; public void setPosterSizes(List<String> posterSizes) {
} this.posterSizes = posterSizes;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">//GEN-BEGIN:setterMethods public void setProfileSizes(List<String> profileSizes) {
public void setBackdropSizes(List<String> backdropSizes) { this.profileSizes = profileSizes;
this.backdropSizes = backdropSizes; }
}
public void setLogoSizes(List<String> logoSizes) {
public void setBaseUrl(String baseUrl) { this.logoSizes = logoSizes;
this.baseUrl = baseUrl; }
}
public void setSecureBaseUrl(String secureBaseUrl) {
public void setPosterSizes(List<String> posterSizes) { this.secureBaseUrl = secureBaseUrl;
this.posterSizes = posterSizes; }
}
/**
public void setProfileSizes(List<String> profileSizes) { * Copy the data from the passed object to this one
this.profileSizes = profileSizes; *
} * @param config
*/
public void setLogoSizes(List<String> logoSizes) { public void clone(TmdbConfiguration config) {
this.logoSizes = logoSizes; backdropSizes = config.getBackdropSizes();
} baseUrl = config.getBaseUrl();
posterSizes = config.getPosterSizes();
public void setSecureBaseUrl(String secureBaseUrl) { profileSizes = config.getProfileSizes();
this.secureBaseUrl = secureBaseUrl; logoSizes = config.getLogoSizes();
} }
// </editor-fold>
/**
/** * Check that the poster size is valid
* Copy the data from the passed object to this one *
* * @param posterSize
* @param config * @return
*/ */
public void clone(TmdbConfiguration config) { public boolean isValidPosterSize(String posterSize) {
backdropSizes = config.getBackdropSizes(); if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
baseUrl = config.getBaseUrl(); return false;
posterSizes = config.getPosterSizes(); }
profileSizes = config.getProfileSizes(); return posterSizes.contains(posterSize);
logoSizes = config.getLogoSizes(); }
}
/**
/** * Check that the backdrop size is valid
* Check that the poster size is valid *
* * @param backdropSize
* @param posterSize * @return
*/ */
public boolean isValidPosterSize(String posterSize) { public boolean isValidBackdropSize(String backdropSize) {
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
return false; return false;
} }
return posterSizes.contains(posterSize); return backdropSizes.contains(backdropSize);
} }
/** /**
* Check that the backdrop size is valid * Check that the profile size is valid
* *
* @param backdropSize * @param profileSize
*/ * @return
public boolean isValidBackdropSize(String backdropSize) { */
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { public boolean isValidProfileSize(String profileSize) {
return false; if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
} return false;
return backdropSizes.contains(backdropSize); }
} return profileSizes.contains(profileSize);
}
/**
* Check that the profile size is valid /**
* * Check that the logo size is valid
* @param profileSize *
*/ * @param logoSize
public boolean isValidProfileSize(String profileSize) { * @return
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
return false; */
} public boolean isValidSize(String sizeToCheck) {
return logoSizes.contains(logoSize); return (isValidPosterSize(sizeToCheck)
} || 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,59 @@
/* /*
* 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; public class TokenAuthorisation extends AbstractJsonMapping {
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger; /*
import org.slf4j.LoggerFactory; * Properties
*/
public class TokenAuthorisation { @JsonProperty("expires_at")
/* private String expires;
* Logger @JsonProperty("request_token")
*/ private String requestToken;
private static final Logger LOG = LoggerFactory.getLogger(TokenAuthorisation.class); @JsonProperty("success")
/* private Boolean success;
* Properties
*/ public String getExpires() {
@JsonProperty("expires_at") return expires;
private String expires; }
@JsonProperty("request_token")
private String requestToken; public String getRequestToken() {
@JsonProperty("success") return requestToken;
private Boolean success; }
// <editor-fold defaultstate="collapsed" desc="Getter methods"> public Boolean getSuccess() {
public String getExpires() { return success;
return expires; }
}
public void setExpires(String expires) {
public String getRequestToken() { this.expires = expires;
return requestToken; }
}
public void setRequestToken(String requestToken) {
public Boolean getSuccess() { this.requestToken = requestToken;
return success; }
}
// </editor-fold> public void setSuccess(Boolean success) {
this.success = success;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setExpires(String expires) { }
this.expires = expires;
}
public void setRequestToken(String requestToken) {
this.requestToken = requestToken;
}
public void setSuccess(Boolean success) {
this.success = success;
}
// </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,89 @@
/* /*
* 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; public class TokenSession extends AbstractJsonMapping {
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger; /*
import org.slf4j.LoggerFactory; * Properties
*/
public class TokenSession { @JsonProperty("session_id")
/* private String sessionId;
* Logger @JsonProperty("success")
*/ private Boolean success;
@JsonProperty("status_code")
private static final Logger LOG = LoggerFactory.getLogger(TokenSession.class); private String statusCode;
/* @JsonProperty("status_message")
* Properties private String statusMessage;
*/ @JsonProperty("guest_session_id")
@JsonProperty("session_id") private String guestSessionId;
private String sessionId; @JsonProperty("expires_at")
@JsonProperty("success") private String expiresAt;
private Boolean success;
@JsonProperty("status_code") public String getSessionId() {
private String statusCode; return sessionId;
@JsonProperty("status_message") }
private String statusMessage;
@JsonProperty("guest_session_id") public Boolean getSuccess() {
private String guestSessionId; return success;
@JsonProperty("expires_at") }
private String expiresAt;
public String getStatusCode() {
// <editor-fold defaultstate="collapsed" desc="Getter methods"> return statusCode;
public String getSessionId() { }
return sessionId;
} public String getStatusMessage() {
return statusMessage;
public Boolean getSuccess() { }
return success;
} public String getGuestSessionId() {
return guestSessionId;
public String getStatusCode() { }
return statusCode;
} public String getExpiresAt() {
return expiresAt;
public String getStatusMessage() { }
return statusMessage;
} public void setSessionId(String sessionId) {
this.sessionId = sessionId;
public String getGuestSessionId() { }
return guestSessionId;
} public void setSuccess(Boolean success) {
this.success = success;
public String getExpiresAt() { }
return expiresAt;
} public void setStatusCode(String statusCode) {
// </editor-fold> this.statusCode = statusCode;
}
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setSessionId(String sessionId) { public void setStatusMessage(String statusMessage) {
this.sessionId = sessionId; this.statusMessage = statusMessage;
} }
public void setSuccess(Boolean success) { public void setGuestSessionId(String guestSessionId) {
this.success = success; this.guestSessionId = guestSessionId;
} }
public void setStatusCode(String statusCode) { public void setExpiresAt(String expiresAt) {
this.statusCode = statusCode; this.expiresAt = expiresAt;
} }
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
public void setGuestSessionId(String guestSessionId) {
this.guestSessionId = guestSessionId;
}
public void setExpiresAt(String expiresAt) {
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,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 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
/* private String type;
* Website sources
*/ 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 String getType() {
return size; return type;
} }
public String getSource() { public void setName(String name) {
return source; this.name = name;
} }
public String getWebsite() { public void setSize(String size) {
return website; this.size = size;
} }
//</editor-fold>
public void setSource(String source) {
//<editor-fold defaultstate="collapsed" desc="Setter methods"> this.source = source;
public void setName(String name) { }
this.name = name;
} public void setWebsite(String website) {
this.website = website;
public void setSize(String size) { }
this.size = size;
} public void setType(String type) {
this.type = type;
public void setSource(String source) { }
this.source = source;
} @Override
public boolean equals(Object obj) {
public void setWebsite(String website) { if (obj == null) {
this.website = website; return false;
} }
//</editor-fold> if (getClass() != obj.getClass()) {
return false;
/** }
* Handle unknown properties and print a message final Trailer other = (Trailer) obj;
* if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
* @param key return false;
* @param value }
*/ if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
@JsonAnySetter return false;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
sb.append("Unknown property: '").append(key); return false;
sb.append("' value: '").append(value).append("'"); }
LOG.trace(sb.toString()); return true;
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (obj == null) { int hash = 7;
return false; hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
if (getClass() != obj.getClass()) { hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
return false; hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
} return hash;
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,101 @@
/* /*
* 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 public String getEnglishName() {
*/ return englishName;
@JsonProperty("english_name") }
private String englishName;
@JsonProperty("iso_639_1") public String getIsoCode() {
private String isoCode; return isoCode;
@JsonProperty("name") }
private String name;
public String getName() {
//<editor-fold defaultstate="collapsed" desc="Getter methods"> return name;
public String getEnglishName() { }
return englishName;
} public void setEnglishName(String englishName) {
this.englishName = englishName;
public String getIsoCode() { }
return isoCode;
} public void setIsoCode(String isoCode) {
this.isoCode = isoCode;
public String getName() { }
return name;
} public void setName(String name) {
//</editor-fold> this.name = name;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setEnglishName(String englishName) { @Override
this.englishName = englishName; public boolean equals(Object obj) {
} if (obj == null) {
return false;
public void setIsoCode(String isoCode) { }
this.isoCode = isoCode; if (getClass() != obj.getClass()) {
} return false;
}
public void setName(String name) { final Translation other = (Translation) obj;
this.name = name; if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) {
} return false;
//</editor-fold> }
if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) {
/** 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 }
*/ return true;
@JsonAnySetter }
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder(); @Override
sb.append("Unknown property: '").append(key); public int hashCode() {
sb.append("' value: '").append(value).append("'"); int hash = 3;
LOG.trace(sb.toString()); 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);
@Override return hash;
public boolean equals(Object obj) { }
if (obj == null) {
return false; @Override
} public String toString() {
if (getClass() != obj.getClass()) { return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
return false; }
} }
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,50 +1,50 @@
/* /*
* 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.results; package com.omertron.themoviedbapi.results;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* List of the results from TheMovieDb * List of the results from TheMovieDb
* *
* @author Stuart * @author Stuart
* @param <T> * @param <T>
*/ */
public final class TmdbResultsList<T> extends TmdbResults { public final class TmdbResultsList<T> extends TmdbResults {
private List<T> results; private List<T> results;
public TmdbResultsList(List<T> resultList) { public TmdbResultsList(List<T> resultList) {
if (resultList != null) { if (resultList != null) {
results = new ArrayList<T>(resultList); results = new ArrayList<T>(resultList);
} else { } else {
results = new ArrayList<T>(0); results = new ArrayList<T>(0);
} }
} }
public List<T> getResults() { public List<T> getResults() {
return results; return results;
} }
public void setResults(List<T> results) { public void setResults(List<T> results) {
this.results = results; this.results = results;
} }
} }
@@ -1,253 +1,257 @@
/* /*
* 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 java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The API URL that is used to construct the API call * The API URL that is used to construct the API call
* *
* @author Stuart * @author Stuart
*/ */
public class ApiUrl { public class ApiUrl {
/* /*
* Logger * Logger
*/ */
private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class); private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
/* /*
* TheMovieDbApi API Base URL * TheMovieDbApi API Base URL
*/ */
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
/* /*
* Parameter configuration * Parameter configuration
*/ */
private static final String DELIMITER_FIRST = "?"; private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&"; private static final String DELIMITER_SUBSEQUENT = "&";
private static final String DEFAULT_STRING = ""; private static final String DEFAULT_STRING = "";
/* /*
* Properties * Properties
*/ */
private String apiKey; private final String apiKey;
private String method; private final String method;
private String submethod; private final String submethod;
private Map<String, String> arguments = new HashMap<String, String>(); private final Map<String, String> arguments = new HashMap<String, String>();
/* /*
* API Parameters * API Parameters
*/ */
public static final String PARAM_ADULT = "include_adult="; public static final String PARAM_ADULT = "include_adult=";
public static final String PARAM_API_KEY = "api_key="; public static final String PARAM_API_KEY = "api_key=";
public static final String PARAM_COUNTRY = "country="; public static final String PARAM_COUNTRY = "country=";
public static final String PARAM_FAVORITE = "favorite="; public static final String PARAM_FAVORITE = "favorite=";
public static final String PARAM_ID = "id="; public static final String PARAM_ID = "id=";
public static final String PARAM_LANGUAGE = "language="; public static final String PARAM_LANGUAGE = "language=";
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies="; public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
public static final String PARAM_PAGE = "page="; public static final String PARAM_PAGE = "page=";
public static final String PARAM_QUERY = "query="; public static final String PARAM_QUERY = "query=";
public static final String PARAM_SESSION = "session_id="; public static final String PARAM_SESSION = "session_id=";
public static final String PARAM_TOKEN = "request_token="; public static final String PARAM_TOKEN = "request_token=";
public static final String PARAM_VALUE = "value="; public static final String PARAM_VALUE = "value=";
public static final String PARAM_YEAR = "year="; public static final String PARAM_YEAR = "year=";
public static final String PARAM_START_DATE="start_date="; public static final String PARAM_START_DATE = "start_date=";
public static final String PARAM_END_DATE="end_date="; public static final String PARAM_END_DATE = "end_date=";
private static final String APPEND_TO_RESPONSE = "append_to_response="; private static final String APPEND_TO_RESPONSE = "append_to_response=";
//<editor-fold defaultstate="collapsed" desc="Constructor Methods"> //<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/** /**
* Constructor for the simple API URL method without a sub-method * Constructor for the simple API URL method without a sub-method
* *
* @param method * @param apiKey
*/ * @param method
public ApiUrl(String apiKey, String method) { */
this.apiKey = apiKey; public ApiUrl(String apiKey, String method) {
this.method = method; this.apiKey = apiKey;
this.submethod = DEFAULT_STRING; this.method = method;
} this.submethod = DEFAULT_STRING;
}
/**
* Constructor for the API URL with a sub-method /**
* * Constructor for the API URL with a sub-method
* @param method *
* @param submethod * @param apiKey
*/ * @param method
public ApiUrl(String apiKey, String method, String submethod) { * @param submethod
this.apiKey = apiKey; */
this.method = method; public ApiUrl(String apiKey, String method, String submethod) {
this.submethod = submethod; this.apiKey = apiKey;
} this.method = method;
//</editor-fold> this.submethod = submethod;
}
/** //</editor-fold>
* Build the URL from the pre-created arguments.
*/ /**
public URL buildUrl() { * Build the URL from the pre-created arguments.
StringBuilder urlString = new StringBuilder(TMDB_API_BASE); *
* @return
// Get the start of the URL */
urlString.append(method); public URL buildUrl() {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// We have either a queury, or a direct request
if (arguments.containsKey(PARAM_QUERY)) { // Get the start of the URL
// Append the suffix of the API URL urlString.append(method);
if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length()-1); // We have either a queury, or a direct request
} if (arguments.containsKey(PARAM_QUERY)) {
urlString.append(submethod); // Append the suffix of the API URL
if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
// Append the key information urlString.deleteCharAt(urlString.length() - 1);
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); }
urlString.append(apiKey); urlString.append(submethod);
// Append the search term // Append the key information
urlString.append(DELIMITER_SUBSEQUENT); urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(PARAM_QUERY); urlString.append(apiKey);
String query = arguments.get(PARAM_QUERY); // Append the search term
urlString.append(DELIMITER_SUBSEQUENT);
try { urlString.append(PARAM_QUERY);
urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) { String query = arguments.get(PARAM_QUERY);
LOG.trace("Unable to encode query: '{}' trying raw.", query);
// If we can't encode it, try it raw try {
urlString.append(query); urlString.append(URLEncoder.encode(query, "UTF-8"));
} } catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '{}' trying raw.", query);
// Remove the query from the arguments so it is not added later // If we can't encode it, try it raw
arguments.remove(PARAM_QUERY); urlString.append(query);
} else { }
// Append the ID if provided
if (arguments.containsKey(PARAM_ID)) { // Remove the query from the arguments so it is not added later
urlString.append(arguments.get(PARAM_ID)); arguments.remove(PARAM_QUERY);
arguments.remove(PARAM_ID); } else {
} // Append the ID if provided
if (arguments.containsKey(PARAM_ID)) {
// Append the suffix of the API URL urlString.append(arguments.get(PARAM_ID));
if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) { arguments.remove(PARAM_ID);
urlString.deleteCharAt(urlString.length()-1); }
}
urlString.append(submethod); // Append the suffix of the API URL
if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
// Append the key information urlString.deleteCharAt(urlString.length() - 1);
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); }
urlString.append(apiKey); urlString.append(submethod);
}
// Append the key information
for (Map.Entry<String, String> argEntry : arguments.entrySet()) { urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey()); urlString.append(apiKey);
urlString.append(argEntry.getValue()); }
}
for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
try { urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey());
LOG.trace("URL: {}", urlString.toString()); urlString.append(argEntry.getValue());
return new URL(urlString.toString()); }
} catch (MalformedURLException ex) {
LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString()); try {
return null; LOG.trace("URL: {}", urlString.toString());
} finally { return new URL(urlString.toString());
arguments.clear(); } catch (MalformedURLException ex) {
} LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString());
} return null;
} finally {
/** arguments.clear();
* Add arguments individually }
* }
* @param key
* @param value /**
*/ * Add arguments individually
public void addArgument(String key, String value) { *
arguments.put(key, value); * @param key
} * @param value
*/
/** public void addArgument(String key, String value) {
* Add arguments individually arguments.put(key, value);
* }
* @param key
* @param value /**
*/ * Add arguments individually
public void addArgument(String key, int value) { *
arguments.put(key, Integer.toString(value)); * @param key
} * @param value
*/
/** public void addArgument(String key, int value) {
* Add arguments individually arguments.put(key, Integer.toString(value));
* }
* @param key
* @param value /**
*/ * Add arguments individually
public void addArgument(String key, boolean value) { *
arguments.put(key, Boolean.toString(value)); * @param key
} * @param value
*/
/** public void addArgument(String key, boolean value) {
* Add arguments individually arguments.put(key, Boolean.toString(value));
* }
* @param key
* @param value /**
*/ * Add arguments individually
public void addArgument(String key, float value) { *
arguments.put(key, Float.toString(value)); * @param key
} * @param value
*/
/** public void addArgument(String key, float value) {
* Clear the arguments arguments.put(key, Float.toString(value));
*/ }
public void clearArguments() {
arguments.clear(); /**
} * Clear the arguments
*/
/** public void clearArguments() {
* Set the arguments directly arguments.clear();
* }
* @param args
*/ /**
public void setArguments(Map<String, String> args) { * Set the arguments directly
arguments.putAll(args); *
} * @param args
*/
/** public void setArguments(Map<String, String> args) {
* Append any optional parameters to the URL arguments.putAll(args);
* }
* @param appendToResponse
*/ /**
public void appendToResponse(String[] appendToResponse) { * Append any optional parameters to the URL
if (appendToResponse.length > 0) { *
StringBuilder sb = new StringBuilder(); * @param appendToResponse
boolean first = Boolean.TRUE; */
for (String append : appendToResponse) { public void appendToResponse(String[] appendToResponse) {
if (first) { if (appendToResponse.length > 0) {
first = Boolean.FALSE; StringBuilder sb = new StringBuilder();
} else { boolean first = Boolean.TRUE;
sb.append(","); for (String append : appendToResponse) {
} if (first) {
sb.append(append); first = Boolean.FALSE;
} } else {
addArgument(APPEND_TO_RESPONSE, sb.toString()); sb.append(",");
} }
} sb.append(append);
} }
addArgument(APPEND_TO_RESPONSE, sb.toString());
}
}
}
@@ -1,289 +1,323 @@
/* /*
* 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.omertron.themoviedbapi.MovieDbException;
import java.io.BufferedReader; import org.apache.commons.codec.binary.Base64;
import java.io.IOException; import org.slf4j.Logger;
import java.io.InputStreamReader; import org.slf4j.LoggerFactory;
import java.io.StringWriter;
import java.net.HttpURLConnection; import java.io.*;
import java.net.MalformedURLException; import java.net.HttpURLConnection;
import java.net.URL; import java.net.MalformedURLException;
import java.net.URLConnection; import java.net.URL;
import java.nio.charset.Charset; import java.net.URLConnection;
import java.nio.charset.UnsupportedCharsetException; import java.nio.charset.Charset;
import java.util.HashMap; import java.nio.charset.UnsupportedCharsetException;
import java.util.List; import java.util.HashMap;
import java.util.Map; import java.util.List;
import java.util.regex.Matcher; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Matcher;
import org.apache.commons.codec.binary.Base64; import java.util.regex.Pattern;
import org.slf4j.Logger; import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
/**
/** * 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 final Map<String, String> BROWSER_PROPERTIES = new HashMap<String, String>();
private static Map<String, String> browserProperties = new HashMap<String, String>(); private static final 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 (BROWSER_PROPERTIES.isEmpty()) {
if (browserProperties.isEmpty()) { BROWSER_PROPERTIES.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)"); BROWSER_PROPERTIES.put("Accept", "application/json");
browserProperties.put("Accept", "application/json"); BROWSER_PROPERTIES.put("Content-type", "application/json");
} }
} }
public static String request(String url) throws MovieDbException { public static String request(String url) throws MovieDbException {
try { try {
return request(new URL(url)); return request(new URL(url));
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
} }
} }
public static URLConnection openProxiedConnection(URL url) throws MovieDbException { public static URLConnection openProxiedConnection(URL url) throws MovieDbException {
try { try {
if (proxyHost != null) { if (proxyHost != null) {
System.getProperties().put("proxySet", "true"); System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", proxyHost); System.getProperties().put("proxyHost", proxyHost);
System.getProperties().put("proxyPort", proxyPort); System.getProperties().put("proxyPort", proxyPort);
} }
URLConnection cnx = url.openConnection(); URLConnection cnx = url.openConnection();
if (proxyUsername != null) { if (proxyUsername != null) {
cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
} }
return cnx; return cnx;
} catch (IOException ex) { } catch (IOException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
} }
} }
public static String request(URL url) throws MovieDbException { public static String request(URL url) throws MovieDbException {
StringWriter content = null; return request(url, null, Boolean.FALSE);
}
try {
content = new StringWriter(); public static String request(URL url, String jsonBody) throws MovieDbException {
return request(url, jsonBody, Boolean.FALSE);
BufferedReader in = null; }
URLConnection cnx = null;
try { public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
cnx = openProxiedConnection(url);
StringWriter content = null;
sendHeader(cnx);
readHeader(cnx); try {
content = new StringWriter();
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
String line; BufferedReader in = null;
while ((line = in.readLine()) != null) { HttpURLConnection cnx = null;
content.write(line); OutputStreamWriter wr = null;
} try {
} finally { cnx = (HttpURLConnection) openProxiedConnection(url);
if (in != null) {
in.close(); if (isDeleteRequest) {
} cnx.setDoOutput(true);
cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
if (cnx instanceof HttpURLConnection) { cnx.setRequestMethod("DELETE");
((HttpURLConnection) cnx).disconnect(); }
}
} sendHeader(cnx);
return content.toString();
} catch (IOException ex) { if (StringUtils.isNotBlank(jsonBody)) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex); cnx.setDoOutput(true);
} finally { wr = new OutputStreamWriter(cnx.getOutputStream());
if (content != null) { wr.write(jsonBody);
try { }
content.close();
} catch (IOException ex) { readHeader(cnx);
LOG.debug("Failed to close connection: " + ex.getMessage());
} // 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 {
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
private static void sendHeader(URLConnection cnx) { }
populateBrowserProperties();
String line;
// send browser properties while ((line = in.readLine()) != null) {
for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) { content.write(line);
cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); }
} } finally {
// send cookies if (wr != null) {
String cookieHeader = createCookieHeader(cnx); wr.flush();
if (!cookieHeader.isEmpty()) { wr.close();
cnx.setRequestProperty("Cookie", cookieHeader); }
}
} if (in != null) {
in.close();
private static String createCookieHeader(URLConnection cnx) { }
String host = cnx.getURL().getHost();
StringBuilder cookiesHeader = new StringBuilder(); if (cnx instanceof HttpURLConnection) {
for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) { ((HttpURLConnection) cnx).disconnect();
if (host.endsWith(domainCookies.getKey())) { }
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) { }
cookiesHeader.append(cookie.getKey()); return content.toString();
cookiesHeader.append("="); } catch (IOException ex) {
cookiesHeader.append(cookie.getValue()); throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex);
cookiesHeader.append(";"); } finally {
} if (content != null) {
} try {
} content.close();
if (cookiesHeader.length() > 0) { } catch (IOException ex) {
// remove last ; char LOG.debug("Failed to close connection: " + ex.getMessage());
cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); }
} }
return cookiesHeader.toString(); }
} }
private static void readHeader(URLConnection cnx) { private static void sendHeader(URLConnection cnx) {
// read new cookies and update our cookies populateBrowserProperties();
for (Map.Entry<String, List<String>> header : cnx.getHeaderFields().entrySet()) {
if ("Set-Cookie".equals(header.getKey())) { // send browser properties
for (String cookieHeader : header.getValue()) { for (Map.Entry<String, String> browserProperty : BROWSER_PROPERTIES.entrySet()) {
String[] cookieElements = cookieHeader.split(" *; *"); cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
if (cookieElements.length >= 1) { }
String[] firstElem = cookieElements[0].split(" *= *"); // send cookies
String cookieName = firstElem[0]; String cookieHeader = createCookieHeader(cnx);
String cookieValue = firstElem.length > 1 ? firstElem[1] : null; if (!cookieHeader.isEmpty()) {
String cookieDomain = null; cnx.setRequestProperty("Cookie", cookieHeader);
// find cookie domain }
for (int i = 1; i < cookieElements.length; i++) { }
String[] cookieElement = cookieElements[i].split(" *= *");
if ("domain".equals(cookieElement[0])) { private static String createCookieHeader(URLConnection cnx) {
cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; String host = cnx.getURL().getHost();
break; StringBuilder cookiesHeader = new StringBuilder();
} for (Map.Entry<String, Map<String, String>> domainCookies : COOKIES.entrySet()) {
} if (host.endsWith(domainCookies.getKey())) {
if (cookieDomain == null) { for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
// if domain isn't set take current host cookiesHeader.append(cookie.getKey());
cookieDomain = cnx.getURL().getHost(); cookiesHeader.append("=");
} cookiesHeader.append(cookie.getValue());
Map<String, String> domainCookies = cookies.get(cookieDomain); cookiesHeader.append(";");
if (domainCookies == null) { }
domainCookies = new HashMap<String, String>(); }
cookies.put(cookieDomain, domainCookies); }
} if (cookiesHeader.length() > 0) {
// add or replace cookie // remove last ; char
domainCookies.put(cookieName, cookieValue); cookiesHeader.deleteCharAt(cookiesHeader.length() - 1);
} }
} return cookiesHeader.toString();
} }
}
} private static void readHeader(URLConnection cnx) {
// read new cookies and update our cookies
private static Charset getCharset(URLConnection cnx) { for (Map.Entry<String, List<String>> header : cnx.getHeaderFields().entrySet()) {
Charset charset = null; if ("Set-Cookie".equals(header.getKey())) {
// content type will be string like "text/html; charset=UTF-8" or "text/html" for (String cookieHeader : header.getValue()) {
String contentType = cnx.getContentType(); String[] cookieElements = cookieHeader.split(" *; *");
if (contentType != null) { if (cookieElements.length >= 1) {
// changed 'charset' to 'harset' in regexp because some sites send 'Charset' String[] firstElem = cookieElements[0].split(" *= *");
Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); String cookieName = firstElem[0];
if (m.find()) { String cookieValue = firstElem.length > 1 ? firstElem[1] : null;
String encoding = m.group(1); String cookieDomain = null;
try { // find cookie domain
charset = Charset.forName(encoding); for (int i = 1; i < cookieElements.length; i++) {
} catch (UnsupportedCharsetException e) { String[] cookieElement = cookieElements[i].split(" *= *");
// there will be used default charset 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
cookieDomain = cnx.getURL().getHost();
return charset; }
} Map<String, String> domainCookies = COOKIES.get(cookieDomain);
if (domainCookies == null) {
public static String getProxyHost() { domainCookies = new HashMap<String, String>();
return proxyHost; COOKIES.put(cookieDomain, domainCookies);
} }
// add or replace cookie
public static void setProxyHost(String myProxyHost) { domainCookies.put(cookieName, cookieValue);
WebBrowser.proxyHost = myProxyHost; }
} }
}
public static String getProxyPort() { }
return proxyPort; }
}
private static Charset getCharset(URLConnection cnx) {
public static void setProxyPort(String myProxyPort) { Charset charset = null;
WebBrowser.proxyPort = myProxyPort; // content type will be string like "text/html; charset=UTF-8" or "text/html"
} String contentType = cnx.getContentType();
if (contentType != null) {
public static String getProxyUsername() { // changed 'charset' to 'harset' in regexp because some sites send 'Charset'
return proxyUsername; Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType);
} if (m.find()) {
String encoding = m.group(1);
public static void setProxyUsername(String myProxyUsername) { try {
WebBrowser.proxyUsername = myProxyUsername; charset = Charset.forName(encoding);
} } catch (UnsupportedCharsetException e) {
// there will be used default charset
public static String getProxyPassword() { }
return proxyPassword; }
} }
if (charset == null) {
public static void setProxyPassword(String myProxyPassword) { charset = Charset.defaultCharset();
WebBrowser.proxyPassword = myProxyPassword; }
if (proxyUsername != null) { return charset;
proxyEncodedPassword = proxyUsername + ":" + proxyPassword; }
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;
}
}
@@ -19,23 +19,16 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
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 abstract class AbstractWrapper { public abstract class AbstractWrapper extends AbstractJsonMapping implements Serializable {
private Logger log; private static final long serialVersionUID = 1L;
public AbstractWrapper(Class classToLog) {
this.log = LoggerFactory.getLogger(classToLog);
}
/** /**
* Get a list of the enums passed * Get a list of the enums passed
@@ -52,23 +45,4 @@ public abstract class AbstractWrapper {
return new ArrayList<E>(EnumSet.allOf(clz)); return new ArrayList<E>(EnumSet.allOf(clz));
} }
} }
/**
* 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);
}
} }
@@ -26,10 +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
*/
@JsonProperty("page") @JsonProperty("page")
private int page; private int page;
@@ -37,10 +34,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")
public AbstractWrapperAll(Class classToLog) { private ResultDates dates = new ResultDates();
super(classToLog);
}
@Override @Override
public int getPage() { public int getPage() {
@@ -57,6 +52,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 +71,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;
}
} }
@@ -1,50 +1,44 @@
/* /*
* 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.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
/** /**
* Base class for the wrappers * Base class for the wrappers
* *
* @author Stuart * @author Stuart
*/ */
public class AbstractWrapperId extends AbstractWrapper implements IWrapperId { public class AbstractWrapperId extends AbstractWrapper implements IWrapperId {
/*
* Properties private static final long serialVersionUID = 1L;
*/ @JsonProperty("id")
private int id;
@JsonProperty("id")
private int id; @Override
public int getId() {
public AbstractWrapperId(Class classToLog) { return id;
super(classToLog); }
}
@Override
@Override public void setId(int id) {
public int getId() { this.id = id;
return id; }
} }
@Override
public void setId(int id) {
this.id = id;
}
}
@@ -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,88 @@
/*
* 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.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);
}
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.AlternativeTitle;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperAlternativeTitles extends AbstractWrapperId { public class WrapperAlternativeTitles extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("titles") @JsonProperty("titles")
private List<AlternativeTitle> titles; private List<AlternativeTitle> titles;
public WrapperAlternativeTitles() {
super(WrapperAlternativeTitles.class);
}
public List<AlternativeTitle> getTitles() { public List<AlternativeTitle> getTitles() {
return titles; return titles;
} }
@@ -15,7 +15,7 @@ public class WrapperChanges {
@JsonProperty("changes") @JsonProperty("changes")
private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>(); private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>();
private Map<String, Object> newItems = new HashMap<String, Object>(); private final Map<String, Object> newItems = new HashMap<String, Object>();
public List<ChangeKeyItem> getChangedItems() { public List<ChangeKeyItem> getChangedItems() {
return changedItems; return changedItems;
@@ -32,10 +32,6 @@ public class WrapperCollection extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<Collection> results; private List<Collection> results;
public WrapperCollection() {
super(WrapperCollection.class);
}
public List<Collection> getResults() { public List<Collection> getResults() {
return results; return results;
} }
@@ -32,10 +32,6 @@ public class WrapperCompany extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<Company> results; private List<Company> results;
public WrapperCompany() {
super(WrapperCompany.class);
}
public List<Company> getResults() { public List<Company> getResults() {
return results; return results;
} }
@@ -32,10 +32,6 @@ public class WrapperCompanyMovies extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> results; private List<MovieDb> results;
public WrapperCompanyMovies() {
super(WrapperCompanyMovies.class);
}
public List<MovieDb> getResults() { public List<MovieDb> getResults() {
return results; return results;
} }
@@ -35,10 +35,6 @@ public class WrapperConfig extends AbstractWrapper {
@JsonProperty("change_keys") @JsonProperty("change_keys")
private List<String> changeKeys = Collections.EMPTY_LIST; private List<String> changeKeys = Collections.EMPTY_LIST;
public WrapperConfig() {
super(WrapperConfig.class);
}
public TmdbConfiguration getTmdbConfiguration() { public TmdbConfiguration getTmdbConfiguration() {
return tmdbConfiguration; return tmdbConfiguration;
} }
@@ -33,10 +33,6 @@ public class WrapperGenres extends AbstractWrapper {
@JsonProperty("genres") @JsonProperty("genres")
private List<Genre> genres; private List<Genre> genres;
public WrapperGenres() {
super(WrapperGenres.class);
}
public List<Genre> getGenres() { public List<Genre> getGenres() {
return genres; return genres;
} }
@@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Artwork; import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ArtworkType; import com.omertron.themoviedbapi.model.ArtworkType;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@@ -31,8 +32,9 @@ import java.util.List;
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperImages extends AbstractWrapperAll { public class WrapperImages extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("backdrops") @JsonProperty("backdrops")
private List<Artwork> backdrops = Collections.EMPTY_LIST; private List<Artwork> backdrops = Collections.EMPTY_LIST;
@JsonProperty("posters") @JsonProperty("posters")
@@ -40,10 +42,6 @@ public class WrapperImages extends AbstractWrapperAll {
@JsonProperty("profiles") @JsonProperty("profiles")
private List<Artwork> profiles = Collections.EMPTY_LIST; private List<Artwork> profiles = Collections.EMPTY_LIST;
public WrapperImages() {
super(WrapperImages.class);
}
public List<Artwork> getBackdrops() { public List<Artwork> getBackdrops() {
return backdrops; return backdrops;
} }
@@ -73,6 +71,7 @@ public class WrapperImages extends AbstractWrapperAll {
* *
* Leaving the parameters blank will return all types * Leaving the parameters blank will return all types
* *
* @param artworkList
* @return * @return
*/ */
public List<Artwork> getAll(ArtworkType... artworkList) { public List<Artwork> getAll(ArtworkType... artworkList) {
@@ -32,10 +32,6 @@ public class WrapperJobList extends AbstractWrapper {
@JsonProperty("jobs") @JsonProperty("jobs")
private List<JobDepartment> jobs; private List<JobDepartment> jobs;
public WrapperJobList() {
super(WrapperJobList.class);
}
public List<JobDepartment> getJobs() { public List<JobDepartment> getJobs() {
return jobs; return jobs;
} }
@@ -32,10 +32,6 @@ public class WrapperKeywordMovies extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<KeywordMovie> results; private List<KeywordMovie> results;
public WrapperKeywordMovies() {
super(WrapperKeywordMovies.class);
}
public List<KeywordMovie> getResults() { public List<KeywordMovie> getResults() {
return results; return results;
} }
@@ -32,10 +32,6 @@ public class WrapperKeywords extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<Keyword> results; private List<Keyword> results;
public WrapperKeywords() {
super(WrapperKeywords.class);
}
public List<Keyword> getResults() { public List<Keyword> getResults() {
return results; return results;
} }
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperMovie extends AbstractWrapperAll { public class WrapperMovie extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> movies; private List<MovieDb> movies;
public WrapperMovie() {
super(WrapperMovie.class);
}
public List<MovieDb> getMovies() { public List<MovieDb> getMovies() {
return movies; return movies;
} }
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Person; import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCast; import com.omertron.themoviedbapi.model.PersonCast;
import com.omertron.themoviedbapi.model.PersonCrew; import com.omertron.themoviedbapi.model.PersonCrew;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -30,17 +31,14 @@ import java.util.List;
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieCasts extends AbstractWrapperId { public class WrapperMovieCasts extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("cast") @JsonProperty("cast")
private List<PersonCast> cast; private List<PersonCast> cast;
@JsonProperty("crew") @JsonProperty("crew")
private List<PersonCrew> crew; private List<PersonCrew> crew;
public WrapperMovieCasts() {
super(WrapperMovieCasts.class);
}
public List<PersonCast> getCast() { public List<PersonCast> getCast() {
return cast; return cast;
} }
@@ -0,0 +1,39 @@
/*
* 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 java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ChangedMovie;
public class WrapperMovieChanges extends AbstractWrapperAll {
@JsonProperty("results")
private List<ChangedMovie> results;
public List<ChangedMovie> getResults() {
return results;
}
public void setResults(List<ChangedMovie> results) {
this.results = results;
}
}
@@ -0,0 +1,21 @@
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 List<MovieDbList> getLists() {
return lists;
}
public void setLists(List<MovieDbList> lists) {
this.lists = lists;
}
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.Keyword;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieKeywords extends AbstractWrapperId { public class WrapperMovieKeywords extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("keywords") @JsonProperty("keywords")
private List<Keyword> keywords; private List<Keyword> keywords;
public WrapperMovieKeywords() {
super(WrapperMovieKeywords.class);
}
public List<Keyword> getKeywords() { public List<Keyword> getKeywords() {
return keywords; return keywords;
} }
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.MovieList;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieList extends AbstractWrapperAll { public class WrapperMovieList extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results") @JsonProperty("results")
private List<MovieList> movieList; private List<MovieList> movieList;
public WrapperMovieList() {
super(WrapperMovieList.class);
}
public List<MovieList> getMovieList() { public List<MovieList> getMovieList() {
return movieList; return movieList;
} }
@@ -32,10 +32,6 @@ public class WrapperPerson extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<Person> results; private List<Person> results;
public WrapperPerson() {
super(WrapperPerson.class);
}
public List<Person> getResults() { public List<Person> getResults() {
return results; return results;
} }
@@ -36,10 +36,6 @@ public class WrapperPersonCredits extends AbstractWrapperAll {
@JsonProperty("crew") @JsonProperty("crew")
private List<PersonCredit> crew; private List<PersonCredit> crew;
public WrapperPersonCredits() {
super(WrapperMovieCasts.class);
}
public List<PersonCredit> getCast() { public List<PersonCredit> getCast() {
return cast; return cast;
} }
@@ -32,10 +32,6 @@ public class WrapperPersonList extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<Person> personList; private List<Person> personList;
public WrapperPersonList() {
super(WrapperPersonList.class);
}
public List<Person> getPersonList() { public List<Person> getPersonList() {
return personList; return personList;
} }
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ReleaseInfo; import com.omertron.themoviedbapi.model.ReleaseInfo;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperReleaseInfo extends AbstractWrapperId { public class WrapperReleaseInfo extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("countries") @JsonProperty("countries")
private List<ReleaseInfo> countries; private List<ReleaseInfo> countries;
public WrapperReleaseInfo() {
super(WrapperReleaseInfo.class);
}
public List<ReleaseInfo> getCountries() { public List<ReleaseInfo> getCountries() {
return countries; return countries;
} }
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Reviews; import com.omertron.themoviedbapi.model.Reviews;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperReviews extends AbstractWrapperAll { public class WrapperReviews extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results") @JsonProperty("results")
private List<Reviews> reviews; private List<Reviews> reviews;
public WrapperReviews() {
super(WrapperReviews.class);
}
public List<Reviews> getReviews() { public List<Reviews> getReviews() {
return reviews; return reviews;
} }
@@ -21,6 +21,7 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Trailer;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -28,17 +29,14 @@ import java.util.List;
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperTrailers extends AbstractWrapperId { public class WrapperTrailers extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("quicktime") @JsonProperty("quicktime")
private List<Trailer> quicktime; private List<Trailer> quicktime;
@JsonProperty("youtube") @JsonProperty("youtube")
private List<Trailer> youtube; private List<Trailer> youtube;
public WrapperTrailers() {
super(WrapperTrailers.class);
}
public List<Trailer> getQuicktime() { public List<Trailer> getQuicktime() {
return quicktime; return quicktime;
} }
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Translation; import com.omertron.themoviedbapi.model.Translation;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperTranslations extends AbstractWrapperId { public class WrapperTranslations extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("translations") @JsonProperty("translations")
private List<Translation> translations; private List<Translation> translations;
public WrapperTranslations() {
super(WrapperTranslations.class);
}
public void setTranslations(List<Translation> translations) { public void setTranslations(List<Translation> translations) {
this.translations = translations; this.translations = translations;
} }
@@ -1,72 +1,72 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of the FanartTV API. * This file is part of the FanartTV API.
* *
* The FanartTV API is free software: you can redistribute it and/or modify * The FanartTV 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.
* *
* The FanartTV API is distributed in the hope that it will be useful, * The FanartTV 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 the FanartTV API. If not, see <http://www.gnu.org/licenses/>. * along with the FanartTV API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi; package com.omertron.themoviedbapi;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.logging.LogManager; import java.util.logging.LogManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class TestLogger { public class TestLogger {
private static final Logger LOG = LoggerFactory.getLogger(TestLogger.class); private static final Logger LOG = LoggerFactory.getLogger(TestLogger.class);
private static final String CRLF = "\n"; private static final String CRLF = "\n";
private TestLogger() { private TestLogger() {
throw new UnsupportedOperationException("Class can not be instantiated"); throw new UnsupportedOperationException("Class can not be instantiated");
} }
/** /**
* Configure the logger with a simple in-memory file for the required log level * Configure the logger with a simple in-memory file for the required log level
* *
* @param level The logging level required * @param level The logging level required
* @return True if successful * @return True if successful
*/ */
public static boolean Configure(String level) { public static boolean Configure(String level) {
StringBuilder config = new StringBuilder("handlers = java.util.logging.ConsoleHandler\n"); StringBuilder config = new StringBuilder("handlers = java.util.logging.ConsoleHandler\n");
config.append(".level = ").append(level).append(CRLF); config.append(".level = ").append(level).append(CRLF);
config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF); config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF);
// Only works with Java 7 or later // Only works with Java 7 or later
config.append("java.util.logging.SimpleFormatter.format = [%1$tc %4$s] %2$s - %5$s %6$s%n").append(CRLF); config.append("java.util.logging.SimpleFormatter.format = [%1$tH:%1$tM:%1$tS %4$6s] %2$s - %5$s %6$s%n").append(CRLF);
// Exclude http logging // Exclude http logging
config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF); config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF);
InputStream ins = new ByteArrayInputStream(config.toString().getBytes()); InputStream ins = new ByteArrayInputStream(config.toString().getBytes());
try { try {
LogManager.getLogManager().readConfiguration(ins); LogManager.getLogManager().readConfiguration(ins);
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Failed to configure log manager due to an IO problem", e); LOG.warn("Failed to configure log manager due to an IO problem", e);
return Boolean.FALSE; return Boolean.FALSE;
} }
LOG.debug("Logger initialized to '{}' level", level); LOG.debug("Logger initialized to '{}' level", level);
return Boolean.TRUE; return Boolean.TRUE;
} }
/** /**
* Set the logging level to "ALL" * Set the logging level to "ALL"
* *
* @return True if successful * @return True if successful
*/ */
public static boolean Configure() { public static boolean Configure() {
return Configure("ALL"); return Configure("ALL");
} }
} }
@@ -19,9 +19,31 @@
*/ */
package com.omertron.themoviedbapi; package com.omertron.themoviedbapi;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.omertron.themoviedbapi.model.Account;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork; import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ChangedItem; import com.omertron.themoviedbapi.model.ChangedItem;
import com.omertron.themoviedbapi.model.ChangedMovie;
import com.omertron.themoviedbapi.model.Collection; import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Company;
@@ -37,6 +59,7 @@ import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCredit; import com.omertron.themoviedbapi.model.PersonCredit;
import com.omertron.themoviedbapi.model.ReleaseInfo; import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model.Reviews; import com.omertron.themoviedbapi.model.Reviews;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.TmdbConfiguration; import com.omertron.themoviedbapi.model.TmdbConfiguration;
import com.omertron.themoviedbapi.model.TokenAuthorisation; import com.omertron.themoviedbapi.model.TokenAuthorisation;
import com.omertron.themoviedbapi.model.TokenSession; import com.omertron.themoviedbapi.model.TokenSession;
@@ -44,13 +67,6 @@ import com.omertron.themoviedbapi.model.Trailer;
import com.omertron.themoviedbapi.model.Translation; 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.junit.*;
import static org.junit.Assert.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Test cases for TheMovieDbApi API * Test cases for TheMovieDbApi API
@@ -69,7 +85,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 +93,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 {
} }
@@ -103,7 +122,7 @@ public class TheMovieDbApiTest {
* Test of getConfiguration method, of class TheMovieDbApi. * Test of getConfiguration method, of class TheMovieDbApi.
*/ */
@Test @Test
public void testConfiguration() throws IOException { public void testConfiguration() {
LOG.info("Test Configuration"); LOG.info("Test Configuration");
TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
@@ -115,8 +134,55 @@ 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.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchMovie() throws MovieDbException { public void testSearchMovie() throws MovieDbException {
@@ -138,6 +204,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieInfo method, of class TheMovieDbApi. * Test of getMovieInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieInfo() throws MovieDbException { public void testGetMovieInfo() throws MovieDbException {
@@ -148,6 +216,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieAlternativeTitles method, of class TheMovieDbApi. * Test of getMovieAlternativeTitles method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieAlternativeTitles() throws MovieDbException { public void testGetMovieAlternativeTitles() throws MovieDbException {
@@ -164,6 +234,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieCasts method, of class TheMovieDbApi. * Test of getMovieCasts method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieCasts() throws MovieDbException { public void testGetMovieCasts() throws MovieDbException {
@@ -191,6 +263,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieImages method, of class TheMovieDbApi. * Test of getMovieImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieImages() throws MovieDbException { public void testGetMovieImages() throws MovieDbException {
@@ -202,6 +276,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieKeywords method, of class TheMovieDbApi. * Test of getMovieKeywords method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieKeywords() throws MovieDbException { public void testGetMovieKeywords() throws MovieDbException {
@@ -212,6 +288,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieReleaseInfo method, of class TheMovieDbApi. * Test of getMovieReleaseInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieReleaseInfo() throws MovieDbException { public void testGetMovieReleaseInfo() throws MovieDbException {
@@ -222,6 +300,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieTrailers method, of class TheMovieDbApi. * Test of getMovieTrailers method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieTrailers() throws MovieDbException { public void testGetMovieTrailers() throws MovieDbException {
@@ -232,6 +312,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieTranslations method, of class TheMovieDbApi. * Test of getMovieTranslations method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieTranslations() throws MovieDbException { public void testGetMovieTranslations() throws MovieDbException {
@@ -242,6 +324,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCollectionInfo method, of class TheMovieDbApi. * Test of getCollectionInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetCollectionInfo() throws MovieDbException { public void testGetCollectionInfo() throws MovieDbException {
@@ -266,6 +350,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieInfoImdb method, of class TheMovieDbApi. * Test of getMovieInfoImdb method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieInfoImdb() throws MovieDbException { public void testGetMovieInfoImdb() throws MovieDbException {
@@ -276,6 +362,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getApiKey method, of class TheMovieDbApi. * Test of getApiKey method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testGetApiKey() { public void testGetApiKey() {
@@ -284,6 +371,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getApiBase method, of class TheMovieDbApi. * Test of getApiBase method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testGetApiBase() { public void testGetApiBase() {
@@ -292,6 +380,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getConfiguration method, of class TheMovieDbApi. * Test of getConfiguration method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testGetConfiguration() { public void testGetConfiguration() {
@@ -300,6 +389,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchPeople method, of class TheMovieDbApi. * Test of searchPeople method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchPeople() throws MovieDbException { public void testSearchPeople() throws MovieDbException {
@@ -312,6 +403,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonInfo method, of class TheMovieDbApi. * Test of getPersonInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonInfo() throws MovieDbException { public void testGetPersonInfo() throws MovieDbException {
@@ -322,6 +415,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonCredits method, of class TheMovieDbApi. * Test of getPersonCredits method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonCredits() throws MovieDbException { public void testGetPersonCredits() throws MovieDbException {
@@ -333,6 +428,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonImages method, of class TheMovieDbApi. * Test of getPersonImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonImages() throws MovieDbException { public void testGetPersonImages() throws MovieDbException {
@@ -344,6 +441,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getLatestMovie method, of class TheMovieDbApi. * Test of getLatestMovie method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetLatestMovie() throws MovieDbException { public void testGetLatestMovie() throws MovieDbException {
@@ -355,6 +454,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of compareMovies method, of class TheMovieDbApi. * Test of compareMovies method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testCompareMovies() { public void testCompareMovies() {
@@ -363,6 +463,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of setProxy method, of class TheMovieDbApi. * Test of setProxy method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testSetProxy() { public void testSetProxy() {
@@ -371,6 +472,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of setTimeout method, of class TheMovieDbApi. * Test of setTimeout method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testSetTimeout() { public void testSetTimeout() {
@@ -379,6 +481,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getNowPlayingMovies method, of class TheMovieDbApi. * Test of getNowPlayingMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetNowPlayingMovies() throws MovieDbException { public void testGetNowPlayingMovies() throws MovieDbException {
@@ -389,6 +493,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPopularMovieList method, of class TheMovieDbApi. * Test of getPopularMovieList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPopularMovieList() throws MovieDbException { public void testGetPopularMovieList() throws MovieDbException {
@@ -399,6 +505,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getTopRatedMovies method, of class TheMovieDbApi. * Test of getTopRatedMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetTopRatedMovies() throws MovieDbException { public void testGetTopRatedMovies() throws MovieDbException {
@@ -409,26 +517,33 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCompanyInfo method, of class TheMovieDbApi. * Test of getCompanyInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@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());
} }
/** /**
* Test of getCompanyMovies method, of class TheMovieDbApi. * Test of getCompanyMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@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());
} }
/** /**
* Test of searchCompanies method, of class TheMovieDbApi. * Test of searchCompanies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchCompanies() throws MovieDbException { public void testSearchCompanies() throws MovieDbException {
@@ -439,6 +554,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getSimilarMovies method, of class TheMovieDbApi. * Test of getSimilarMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetSimilarMovies() throws MovieDbException { public void testGetSimilarMovies() throws MovieDbException {
@@ -449,6 +566,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGenreList method, of class TheMovieDbApi. * Test of getGenreList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetGenreList() throws MovieDbException { public void testGetGenreList() throws MovieDbException {
@@ -459,6 +578,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGenreMovies method, of class TheMovieDbApi. * Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetGenreMovies() throws MovieDbException { public void testGetGenreMovies() throws MovieDbException {
@@ -469,6 +590,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getUpcoming method, of class TheMovieDbApi. * Test of getUpcoming method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetUpcoming() throws Exception { public void testGetUpcoming() throws Exception {
@@ -479,6 +602,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCollectionImages method, of class TheMovieDbApi. * Test of getCollectionImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetCollectionImages() throws Exception { public void testGetCollectionImages() throws Exception {
@@ -489,6 +614,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getAuthorisationToken method, of class TheMovieDbApi. * Test of getAuthorisationToken method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetAuthorisationToken() throws Exception { public void testGetAuthorisationToken() throws Exception {
@@ -503,13 +630,16 @@ public class TheMovieDbApiTest {
* Test of getSessionToken method, of class TheMovieDbApi. * Test of getSessionToken method, of class TheMovieDbApi.
* *
* 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
*
* @throws MovieDbException
*/ */
@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);
@@ -519,6 +649,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGuestSessionToken method, of class TheMovieDbApi. * Test of getGuestSessionToken method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not ready yet") @Ignore("Not ready yet")
public void testGetGuestSessionToken() throws Exception { public void testGetGuestSessionToken() throws Exception {
@@ -540,6 +672,8 @@ public class TheMovieDbApiTest {
* Test of getMovieChanges method,of class TheMovieDbApi * Test of getMovieChanges method,of class TheMovieDbApi
* *
* TODO: Do not test this until it is fixed * TODO: Do not test this until it is fixed
*
* @throws MovieDbException
*/ */
@Ignore("Do not test this until it is fixed") @Ignore("Do not test this until it is fixed")
public void testGetMovieChanges() throws Exception { public void testGetMovieChanges() throws Exception {
@@ -570,6 +704,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchCollection method, of class TheMovieDbApi. * Test of searchCollection method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchCollection() throws Exception { public void testSearchCollection() throws Exception {
@@ -583,6 +719,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchList method, of class TheMovieDbApi. * Test of searchList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchList() throws Exception { public void testSearchList() throws Exception {
@@ -596,6 +734,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchKeyword method, of class TheMovieDbApi. * Test of searchKeyword method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchKeyword() throws Exception { public void testSearchKeyword() throws Exception {
@@ -611,22 +751,65 @@ public class TheMovieDbApiTest {
* Test of postMovieRating method, of class TheMovieDbApi. * Test of postMovieRating method, of class TheMovieDbApi.
* *
* 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
*
* @throws MovieDbException
*/ */
@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);
} }
/** /**
* Test of getPersonChanges method, of class TheMovieDbApi. * Test of getPersonChanges method, of class TheMovieDbApi.
* *
* @throws MovieDbException
*/ */
@Ignore("Not ready yet") @Ignore("Not ready yet")
public void testGetPersonChanges() throws Exception { public void testGetPersonChanges() throws Exception {
@@ -638,6 +821,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getList method, of class TheMovieDbApi. * Test of getList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetList() throws Exception { public void testGetList() throws Exception {
@@ -649,6 +834,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getKeyword method, of class TheMovieDbApi. * Test of getKeyword method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetKeyword() throws Exception { public void testGetKeyword() throws Exception {
@@ -659,6 +846,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getKeywordMovies method, of class TheMovieDbApi. * Test of getKeywordMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetKeywordMovies() throws Exception { public void testGetKeywordMovies() throws Exception {
@@ -670,6 +859,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getReviews method, of class TheMovieDbApi. * Test of getReviews method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetReviews() throws Exception { public void testGetReviews() throws Exception {
@@ -682,6 +873,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of compareMovies method, of class TheMovieDbApi. * Test of compareMovies method, of class TheMovieDbApi.
*
*/ */
@Ignore("Not required") @Ignore("Not required")
public void testCompareMovies_3args() { public void testCompareMovies_3args() {
@@ -689,6 +881,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of compareMovies method, of class TheMovieDbApi. * Test of compareMovies method, of class TheMovieDbApi.
*
*/ */
@Ignore("Not required") @Ignore("Not required")
public void testCompareMovies_4args() { public void testCompareMovies_4args() {
@@ -696,13 +889,17 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonPopular method, of class TheMovieDbApi. * Test of getPersonPopular method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not required") @Ignore("Not required")
public void testGetPersonPopular_0args() throws Exception { public void testGetPersonPopular_0args() {
} }
/** /**
* Test of getPersonPopular method, of class TheMovieDbApi. * Test of getPersonPopular method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonPopular_int() throws Exception { public void testGetPersonPopular_int() throws Exception {
@@ -714,6 +911,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGenreMovies method, of class TheMovieDbApi. * Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not required") @Ignore("Not required")
public void testGetGenreMovies_3args() throws Exception { public void testGetGenreMovies_3args() throws Exception {
@@ -721,6 +920,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGenreMovies method, of class TheMovieDbApi. * Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not required") @Ignore("Not required")
public void testGetGenreMovies_4args() throws Exception { public void testGetGenreMovies_4args() throws Exception {
@@ -728,20 +929,23 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieChangesList method, of class TheMovieDbApi. * Test of getMovieChangesList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not ready yet") @Test
public void testGetMovieChangesList() throws Exception { public void testGetMovieChangesList() throws Exception {
LOG.info("getMovieChangesList"); LOG.info("getMovieChangesList");
int page = 0; int page = 0;
String startDate = ""; String startDate = "";
String endDate = ""; String endDate = "";
tmdb.getMovieChangesList(page, startDate, endDate); TmdbResultsList<ChangedMovie> result = tmdb.getMovieChangesList(page, startDate, endDate);
// TODO review the generated test code and remove the default call to fail. assertFalse("No movie changes.", result.getResults().isEmpty());
fail("The test case is a prototype.");
} }
/** /**
* Test of getPersonChangesList method, of class TheMovieDbApi. * Test of getPersonChangesList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not ready yet") @Ignore("Not ready yet")
public void testGetPersonChangesList() throws Exception { public void testGetPersonChangesList() throws Exception {
@@ -756,6 +960,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getJobs method, of class TheMovieDbApi. * Test of getJobs method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetJobs() throws Exception { public void testGetJobs() throws Exception {
@@ -766,6 +972,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getDiscover method, of class TheMovieDbApi. * Test of getDiscover method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Ignore("Not required") @Ignore("Not required")
public void testGetDiscover_14args() throws Exception { public void testGetDiscover_14args() throws Exception {
@@ -773,6 +981,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getDiscover method, of class TheMovieDbApi. * Test of getDiscover method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetDiscover_Discover() throws Exception { public void testGetDiscover_Discover() throws Exception {