28 Commits

Author SHA1 Message Date
Omertron 1189d6babd [maven-release-plugin] prepare release themoviedbapi-3.10 2014-11-18 12:12:44 +00:00
Stuart Boston 82c8b31f9f Remove some magic numbers 2014-10-15 09:21:25 +01:00
Stuart Boston d25c09f219 Use Apace Commons EqualsBuilder and HashCodeBuilder 2014-10-15 09:09:38 +01:00
Stuart Boston 75c9142385 Abstract some duplicate code 2014-10-14 14:54:38 +01:00
Stuart Boston d5fc5e279d Correct logger 2014-10-14 14:34:05 +01:00
Stuart Boston 00b24e3bdc Keep exception 2014-10-14 14:33:55 +01:00
Stuart Boston 8572433707 Unused method parameters 2014-10-14 14:28:28 +01:00
Stuart Boston a2f88915a5 Create some string constants 2014-10-14 14:18:04 +01:00
Stuart Boston f05dbb817f Fix bug with parent company 2014-10-14 14:16:50 +01:00
Stuart Boston 6ed9d9ea4c Useless parentheses around expressions should be removed to prevent any misunderstanding 2014-10-14 14:03:37 +01:00
Stuart Boston 2e7c85a41a Change to emptyList() 2014-10-14 13:49:42 +01:00
Stuart Boston 4ee48e15c2 Fix for null year comparison 2014-10-14 13:49:29 +01:00
Omertron 1e1cceceac Updated POM versions 2014-10-08 15:20:08 +02:00
Stuart Boston 48a8ff4e29 remove unused method 2014-10-02 11:29:14 +01:00
Stuart Boston c2d2c7cbe3 Fixed Session Tests 2014-10-01 17:10:48 +01:00
Stuart Boston 5c6f6fd9b1 Add missing fields to model 2014-10-01 17:05:54 +01:00
Stuart Boston f908794e2b Fixed properties load 2014-10-01 14:43:42 +01:00
Stuart Boston 85eb7a5a4a Add properties file for testing API 2014-10-01 13:48:57 +01:00
Stuart Boston d7fd35c4d5 Merge pull request #16 from mlaggner/master
changed MovieDbException to store also the url causing the exception
2014-09-23 19:57:21 +01:00
Manuel Laggner e465c9cfdd changed MovieDbException to store also the url causing the exception 2014-09-21 18:38:41 +02:00
Stuart Boston 46bfa7a324 Update TheMovieDbApiTest.java 2014-05-29 13:16:40 +01:00
Stuart Boston 021daccadc Fix issue #15
Throw an exception if there is a bad connection
2014-04-09 12:40:02 +01:00
Stuart Boston 421084737c Updated POM versions 2014-03-05 15:54:39 +00:00
Stuart Boston 88f120923e Add still sizes to config 2014-01-20 21:02:10 +00:00
Stuart Boston d5c996aef6 Update copyright date 2014-01-16 12:36:50 +00:00
Stuart Boston 8c1aabf1d3 Prevent null pointer exception if trailers are null 2014-01-16 12:27:44 +00:00
Stuart Boston c0653861c0 Add case insensitive compare method 2013-12-29 17:56:03 +00:00
Omertron d3c0c70fc9 [maven-release-plugin] prepare for next development iteration 2013-12-22 17:28:56 +01:00
82 changed files with 985 additions and 748 deletions
+1
View File
@@ -7,3 +7,4 @@
/target/
/nbactions.xml
testing.properties
+9 -4
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<version>9</version>
</parent>
<prerequisites>
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId>
<version>3.9</version>
<version>3.10</version>
<packaging>jar</packaging>
<name>API-The MovieDB</name>
@@ -71,11 +71,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<distribution.format>zip</distribution.format>
<version.jackson>2.3.0</version.jackson>
<version.slf4j>1.7.5</version.slf4j>
<version.jackson>2.4.3</version.jackson>
<version.slf4j>1.7.7</version.slf4j>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!--TESTING-->
<dependency>
<groupId>junit</groupId>
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -19,6 +19,8 @@
*/
package com.omertron.themoviedbapi;
import java.net.URL;
public class MovieDbException extends Exception {
private static final long serialVersionUID = 1L;
@@ -64,18 +66,35 @@ public class MovieDbException extends Exception {
private final MovieDbExceptionType exceptionType;
private final String response;
private final String url;
public MovieDbException(final MovieDbExceptionType exceptionType, final String response) {
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final String url) {
super();
this.exceptionType = exceptionType;
this.response = response;
this.url = url;
}
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final URL url) {
super();
this.exceptionType = exceptionType;
this.response = response;
this.url = url.toExternalForm();
}
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final Throwable cause) {
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final String url, final Throwable cause) {
super(cause);
this.exceptionType = exceptionType;
this.response = response;
this.url = url;
}
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final URL url, final Throwable cause) {
super(cause);
this.exceptionType = exceptionType;
this.response = response;
this.url = url.toExternalForm();
}
public MovieDbExceptionType getExceptionType() {
return exceptionType;
@@ -84,4 +103,8 @@ public class MovieDbException extends Exception {
public String getResponse() {
return response;
}
public String getUrl(){
return url;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,64 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
*
* @author Stuart.Boston
*/
public class AbstractIdName extends AbstractJsonMapping {
private static final long serialVersionUID = 2L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(final Object obj) {
if (obj instanceof AbstractIdName) {
final AbstractIdName other = (AbstractIdName) obj;
return new EqualsBuilder()
.append(name, other.name)
.append(id, other.id)
.isEquals();
} else {
return false;
}
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(id)
.append(name)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,13 +20,12 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
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;
import java.io.Serializable;
/**
* Abstract class to handle any unknown properties by outputting a log message
*
@@ -34,19 +33,7 @@ import java.io.Serializable;
*/
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;
}
private static final Logger LOG = LoggerFactory.getLogger(AbstractJsonMapping.class);
/**
* Handle unknown properties and print a message
@@ -60,7 +47,7 @@ public abstract class AbstractJsonMapping implements Serializable {
unknown.append(": Unknown property='").append(key);
unknown.append("' value='").append(value).append("'");
getLogger().trace(unknown.toString());
LOG.trace(unknown.toString());
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,8 +20,9 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author Stuart
@@ -60,27 +61,22 @@ public class AlternativeTitle implements Serializable {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof AlternativeTitle) {
final AlternativeTitle other = (AlternativeTitle) obj;
return new EqualsBuilder()
.append(country, other.country)
.append(title, other.title)
.isEquals();
} else {
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;
return new HashCodeBuilder()
.append(country)
.append(title)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,6 +20,8 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* The artwork type information
@@ -30,6 +32,8 @@ public class Artwork extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private String id;
@JsonProperty("aspect_ratio")
private float aspectRatio;
@JsonProperty("file_path")
@@ -84,6 +88,10 @@ public class Artwork extends AbstractJsonMapping {
return flag;
}
public String getId() {
return id;
}
public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType;
}
@@ -120,45 +128,36 @@ public class Artwork extends AbstractJsonMapping {
this.flag = flag;
}
public void setId(String id) {
this.id = id;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof Artwork) {
final Artwork other = (Artwork) obj;
return new EqualsBuilder()
.append(aspectRatio, other.aspectRatio)
.append(filePath, other.filePath)
.append(language, other.language)
.append(height, other.height)
.append(width, other.width)
.append(artworkType, other.artworkType)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
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;
return new HashCodeBuilder()
.append(aspectRatio)
.append(filePath)
.append(height)
.append(width)
.append(language)
.append(artworkType)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,9 +1,27 @@
/*
* Copyright (c) 2004-2014 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.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -1,9 +1,27 @@
/*
* Copyright (c) 2004-2014 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.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -22,6 +22,8 @@ package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author stuart.boston
@@ -103,37 +105,28 @@ public class Collection extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof Collection) {
final Collection other = (Collection) obj;
return new EqualsBuilder()
.append(id, other.id)
.append(name, other.name)
.append(title, other.title)
.append(backdropPath, other.backdropPath)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
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;
return new HashCodeBuilder()
.append(id)
.append(backdropPath)
.append(title)
.append(name)
.append(posterPath)
.append(releaseDate)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -104,7 +104,7 @@ public class Company extends AbstractJsonMapping {
public void setParentCompany(int id, String name, String logoPath) {
Company parent = new Company();
parent.setCompanyId(companyId);
parent.setCompanyId(id);
parent.setName(name);
parent.setLogoPath(logoPath);
this.parentCompany = parent;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -19,12 +19,13 @@
*/
package com.omertron.themoviedbapi.model;
import org.apache.commons.lang3.StringUtils;
import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_ADULT;
import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_LANGUAGE;
import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_PAGE;
import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_YEAR;
import java.util.HashMap;
import java.util.Map;
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
import org.apache.commons.lang3.StringUtils;
/**
* Generate a discover object for use in the MovieDbApi
@@ -273,6 +274,6 @@ public class Discover {
* @return
*/
private boolean checkYear(int year) {
return (year >= YEAR_MIN && year <= YEAR_MAX);
return year >= YEAR_MIN && year <= YEAR_MAX;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -19,63 +19,12 @@
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
/**
* @author stuart.boston
*/
@JsonRootName("genre")
public class Genre extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
@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;
}
public class Genre extends AbstractIdName {
// Nothing to override from the base class.
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -19,64 +19,12 @@
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
/**
* @author stuart.boston
*/
@JsonRootName("keyword")
public class Keyword extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
@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;
}
public class Keyword extends AbstractIdName {
// Nothing to override from the base class.
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -21,6 +21,8 @@ package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author stuart.boston
@@ -55,27 +57,22 @@ public class Language extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof Language) {
final Language other = (Language) obj;
return new EqualsBuilder()
.append(isoCode, other.isoCode)
.append(name, other.name)
.isEquals();
} else {
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;
return new HashCodeBuilder()
.append(isoCode)
.append(name)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,9 +20,19 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.wrapper.*;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
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.util.List;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* Movie Bean
@@ -389,32 +399,25 @@ public class MovieDb extends AbstractJsonMapping {
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof MovieDb) {
final MovieDb other = (MovieDb) obj;
return new EqualsBuilder()
.append(id, other.id)
.append(imdbID, other.imdbID)
.append(runtime, other.runtime)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MovieDb other = (MovieDb) obj;
if (this.id != other.id) {
return false;
}
if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) {
return false;
}
if (this.runtime != other.runtime) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 89 * hash + this.id;
hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0);
hash = 89 * hash + this.runtime;
return hash;
return new HashCodeBuilder()
.append(id)
.append(imdbID)
.append(runtime)
.toHashCode();
}
// </editor-fold>
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,7 +20,6 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections;
import java.util.List;
@@ -40,7 +39,7 @@ public class MovieDbList extends AbstractJsonMapping {
@JsonProperty("favorite_count")
private int favoriteCount;
@JsonProperty("items")
private List<MovieDb> items = Collections.EMPTY_LIST;
private List<MovieDb> items = Collections.emptyList();
@JsonProperty("item_count")
private int itemCount;
@JsonProperty("iso_639_1")
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,10 +20,11 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author stuart.boston
@@ -75,6 +76,8 @@ public class Person extends AbstractJsonMapping {
private String imdbId = DEFAULT_STRING;
@JsonProperty("popularity")
private float popularity = 0.0f;
@JsonProperty("known_for")
private List<PersonCredit> knownFor;
/**
* Add a crew member
@@ -252,49 +255,42 @@ public class Person extends AbstractJsonMapping {
this.popularity = popularity;
}
public List<PersonCredit> getKnownFor() {
return knownFor;
}
public void setKnownFor(List<PersonCredit> knownFor) {
this.knownFor = knownFor;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof Person) {
final Person other = (Person) obj;
return new EqualsBuilder()
.append(id, other.id)
.append(name, other.name)
.append(profilePath, other.profilePath)
.append(personType, other.personType)
.append(department, other.department)
.append(job, other.job)
.append(character, other.character)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Person other = (Person) obj;
if (this.id != other.id) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) {
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;
return new HashCodeBuilder()
.append(id)
.append(name)
.append(profilePath)
.append(personType)
.append(department)
.append(job)
.append(character)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -21,6 +21,8 @@ package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author Stuart
@@ -44,6 +46,8 @@ public class PersonCast extends AbstractJsonMapping {
private String profilePath;
@JsonProperty("cast_id")
private int castId;
@JsonProperty("credit_id")
private String creditId;
public String getCharacter() {
return character;
@@ -93,41 +97,38 @@ public class PersonCast extends AbstractJsonMapping {
this.castId = castId;
}
public String getCreditId() {
return creditId;
}
public void setCreditId(String creditId) {
this.creditId = creditId;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof PersonCast) {
final PersonCast other = (PersonCast) obj;
return new EqualsBuilder()
.append(id, other.id)
.append(name, other.name)
.append(character, other.character)
.append(order, other.order)
.append(profilePath, other.profilePath)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
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;
return new HashCodeBuilder()
.append(id)
.append(character)
.append(name)
.append(order)
.append(profilePath)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -40,6 +40,8 @@ public class PersonCredit extends AbstractJsonMapping {
private String movieOriginalTitle = DEFAULT_STRING;
@JsonProperty("poster_path")
private String posterPath = DEFAULT_STRING;
@JsonProperty("backdrop_path")
private String backdropPath = DEFAULT_STRING;
@JsonProperty("release_date")
private String releaseDate = DEFAULT_STRING;
@JsonProperty("title")
@@ -50,7 +52,17 @@ public class PersonCredit extends AbstractJsonMapping {
private String job = DEFAULT_STRING;
@JsonProperty("adult")
private String adult = DEFAULT_STRING;
@JsonProperty("credit_id")
private String creditId = DEFAULT_STRING;
private PersonType personType = PersonType.PERSON;
@JsonProperty("popularity")
private float popularity;
@JsonProperty("vote_average")
private float voteAverage;
@JsonProperty("vote_count")
private int voteCount;
@JsonProperty("media_type")
private String mediaType;
public String getCharacter() {
return character;
@@ -92,6 +104,10 @@ public class PersonCredit extends AbstractJsonMapping {
return adult;
}
public String getCreditId() {
return creditId;
}
public void setCharacter(String character) {
this.character = StringUtils.trimToEmpty(character);
}
@@ -131,4 +147,48 @@ public class PersonCredit extends AbstractJsonMapping {
public void setAdult(String adult) {
this.adult = StringUtils.trimToEmpty(adult);
}
public void setCreditId(String creditId) {
this.creditId = creditId;
}
public String getBackdropPath() {
return backdropPath;
}
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
}
public float getPopularity() {
return popularity;
}
public void setPopularity(float popularity) {
this.popularity = popularity;
}
public float getVoteAverage() {
return voteAverage;
}
public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage;
}
public int getVoteCount() {
return voteCount;
}
public void setVoteCount(int voteCount) {
this.voteCount = voteCount;
}
public String getMediaType() {
return mediaType;
}
public void setMediaType(String mediaType) {
this.mediaType = mediaType;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -21,6 +21,8 @@ package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author Stuart
@@ -42,6 +44,8 @@ public class PersonCrew extends AbstractJsonMapping {
private String name;
@JsonProperty("profile_path")
private String profilePath;
@JsonProperty("credit_id")
private String creditId;
public String getDepartment() {
return department;
@@ -63,6 +67,14 @@ public class PersonCrew extends AbstractJsonMapping {
return profilePath;
}
public String getCreditId() {
return creditId;
}
public void setCreditId(String creditId) {
this.creditId = creditId;
}
public void setDepartment(String department) {
this.department = StringUtils.trimToEmpty(department);
}
@@ -85,36 +97,27 @@ public class PersonCrew extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof PersonCrew) {
final PersonCrew other = (PersonCrew) obj;
return new EqualsBuilder()
.append(id, other.id)
.append(name, other.name)
.append(department, other.department)
.append(job, other.job)
.isEquals();
} else {
return false;
}
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;
return new HashCodeBuilder()
.append(id)
.append(department)
.append(job)
.append(name)
.append(profilePath)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -19,64 +19,12 @@
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
/**
* @author stuart.boston
*/
@JsonRootName("production_company")
public class ProductionCompany extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
@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;
}
public class ProductionCompany extends AbstractIdName {
// Nothing to override from the base class.
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -21,6 +21,8 @@ package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author stuart.boston
@@ -56,27 +58,22 @@ public class ProductionCountry extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof ProductionCountry) {
final ProductionCountry other = (ProductionCountry) obj;
return new EqualsBuilder()
.append(name, other.name)
.append(isoCode, other.isoCode)
.isEquals();
} else {
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;
return new HashCodeBuilder()
.append(isoCode)
.append(name)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,6 +20,8 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author Stuart
@@ -64,31 +66,24 @@ public class ReleaseInfo extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof ReleaseInfo) {
final ReleaseInfo other = (ReleaseInfo) obj;
return new EqualsBuilder()
.append(country, other.country)
.append(certification, other.certification)
.append(releaseDate, other.releaseDate)
.isEquals();
} else {
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;
return new HashCodeBuilder()
.append(country)
.append(certification)
.append(releaseDate)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,9 +20,8 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
/**
* @author stuart.boston
@@ -45,6 +44,8 @@ public class TmdbConfiguration extends AbstractJsonMapping {
private List<String> profileSizes;
@JsonProperty("logo_sizes")
private List<String> logoSizes;
@JsonProperty("still_sizes")
private List<String> stillSizes;
public List<String> getBackdropSizes() {
return backdropSizes;
@@ -70,6 +71,10 @@ public class TmdbConfiguration extends AbstractJsonMapping {
return secureBaseUrl;
}
public List<String> getStillSizes() {
return stillSizes;
}
public void setBackdropSizes(List<String> backdropSizes) {
this.backdropSizes = backdropSizes;
}
@@ -94,6 +99,10 @@ public class TmdbConfiguration extends AbstractJsonMapping {
this.secureBaseUrl = secureBaseUrl;
}
public void setStillSizes(List<String> stillSizes) {
this.stillSizes = stillSizes;
}
/**
* Copy the data from the passed object to this one
*
@@ -166,9 +175,9 @@ public class TmdbConfiguration extends AbstractJsonMapping {
* @return
*/
public boolean isValidSize(String sizeToCheck) {
return (isValidPosterSize(sizeToCheck)
return isValidPosterSize(sizeToCheck)
|| isValidBackdropSize(sizeToCheck)
|| isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck));
|| isValidLogoSize(sizeToCheck);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -19,6 +19,9 @@
*/
package com.omertron.themoviedbapi.model;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author Stuart
*/
@@ -83,32 +86,25 @@ public class Trailer extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof Trailer) {
final Trailer other = (Trailer) obj;
return new EqualsBuilder()
.append(name, other.name)
.append(size, other.size)
.append(source, other.source)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Trailer other = (Trailer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
return false;
}
if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash;
return new HashCodeBuilder()
.append(name)
.append(size)
.append(source)
.append(website)
.toHashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,6 +20,8 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@@ -66,32 +68,25 @@ public class Translation extends AbstractJsonMapping {
@Override
public boolean equals(Object obj) {
if (obj == null) {
if (obj instanceof Translation) {
final Translation other = (Translation) obj;
return new EqualsBuilder()
.append(name, other.name)
.append(englishName, other.englishName)
.append(isoCode, other.isoCode)
.isEquals();
} else {
return false;
}
if (getClass() != obj.getClass()) {
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;
return new HashCodeBuilder()
.append(englishName)
.append(isoCode)
.append(name)
.toHashCode();
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -76,7 +76,7 @@ public class PersonCreditDateComparator implements Comparator<PersonCredit>, Ser
int year1 = extractYear(pc1.getReleaseDate());
int year2 = extractYear(pc2.getReleaseDate());
return ascending ? (year1 - year2) : (year2 - year1);
return ascending ? year1 - year2 : year2 - year1;
}
/**
@@ -89,7 +89,7 @@ public class PersonCreditDateComparator implements Comparator<PersonCredit>, Ser
int year = 0;
Matcher m = YEAR_PATTERN.matcher(date);
if (m.find()) {
year = Integer.valueOf(m.group(1)).intValue();
year = Integer.parseInt(m.group(1));
}
// Give up and return 0
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -73,8 +73,12 @@ public abstract class AbstractResults {
}
//</editor-fold>
/**
* This wrapper does not have anything to copy.
*
* @param wrapper
*/
public void copyWrapper(AbstractWrapper wrapper) {
// These results have nothing to copy, so this is just a placeholder
}
/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -137,7 +137,7 @@ public class ApiUrl {
try {
urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '{}' trying raw.", query);
LOG.trace("Unable to encode query: '{}' trying raw.", query, ex);
// If we can't encode it, try it raw
urlString.append(query);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -20,11 +20,11 @@
package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.MovieDbException;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@@ -36,7 +36,10 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Web browser with simple cookies support
@@ -77,7 +80,7 @@ public final class WebBrowser {
try {
return request(new URL(url));
} catch (MalformedURLException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, url, ex);
}
}
@@ -97,7 +100,7 @@ public final class WebBrowser {
return cnx;
} catch (IOException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, url, ex);
}
}
@@ -122,6 +125,11 @@ public final class WebBrowser {
try {
cnx = (HttpURLConnection) openProxiedConnection(url);
// If we get a null connection, then throw an exception
if (cnx == null) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, "No HTTP connection could be made.", url);
}
if (isDeleteRequest) {
cnx.setDoOutput(true);
cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
@@ -165,7 +173,7 @@ public final class WebBrowser {
}
return content.toString();
} catch (IOException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex);
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, url, ex);
} finally {
if (content != null) {
try {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,13 +1,32 @@
/*
* Copyright (c) 2004-2014 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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ChangeKeyItem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -33,7 +33,7 @@ public class WrapperConfig extends AbstractWrapper {
@JsonProperty("images")
private TmdbConfiguration tmdbConfiguration;
@JsonProperty("change_keys")
private List<String> changeKeys = Collections.EMPTY_LIST;
private List<String> changeKeys = Collections.emptyList();
public TmdbConfiguration getTmdbConfiguration() {
return tmdbConfiguration;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -36,11 +36,11 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("backdrops")
private List<Artwork> backdrops = Collections.EMPTY_LIST;
private List<Artwork> backdrops = Collections.emptyList();
@JsonProperty("posters")
private List<Artwork> posters = Collections.EMPTY_LIST;
private List<Artwork> posters = Collections.emptyList();
@JsonProperty("profiles")
private List<Artwork> profiles = Collections.EMPTY_LIST;
private List<Artwork> profiles = Collections.emptyList();
public List<Artwork> getBackdrops() {
return backdrops;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,8 +1,26 @@
/*
* Copyright (c) 2004-2014 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.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDbList;
import java.util.List;
public class WrapperMovieDbList extends AbstractWrapperAll {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -54,7 +54,7 @@ public class WrapperTrailers extends AbstractWrapperId implements Serializable {
}
/**
* Get a combined list of the trailers with their source website
* Get a combined list of the trailers with their source
*
* @return
*/
@@ -62,14 +62,19 @@ public class WrapperTrailers extends AbstractWrapperId implements Serializable {
List<Trailer> trailers = new ArrayList<Trailer>();
// Add the trailer to the return list along with it's source
for (Trailer trailer : quicktime) {
trailer.setWebsite(Trailer.WEBSITE_QUICKTIME);
trailers.add(trailer);
if (quicktime != null) {
for (Trailer trailer : quicktime) {
trailer.setWebsite(Trailer.WEBSITE_QUICKTIME);
trailers.add(trailer);
}
}
// Add the trailer to the return list along with it's source
for (Trailer trailer : youtube) {
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
trailers.add(trailer);
if (youtube != null) {
for (Trailer trailer : youtube) {
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
trailers.add(trailer);
}
}
return trailers;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -1,28 +1,35 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of the FanartTV API.
* This file is part of TheMovieDB API.
*
* The FanartTV 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
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* The FanartTV 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
* 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 the FanartTV 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;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import java.util.logging.LogManager;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,4 +76,59 @@ public class TestLogger {
public static boolean Configure() {
return Configure("ALL");
}
/**
* Load properties from a file
*
* @param props
* @param propertyFile
*/
public static void loadProperties(Properties props, File propertyFile) {
InputStream is = null;
try {
is = new FileInputStream(propertyFile);
props.load(is);
} catch (Exception ex) {
LOG.warn("Failed to load properties file", ex);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ex) {
LOG.warn("Failed to close properties file", ex);
}
}
}
}
/**
* Save properties to a file
*
* @param props
* @param propertyFile
* @param headerText
*/
public static void saveProperties(Properties props, File propertyFile, String headerText) {
OutputStream out = null;
try {
out = new FileOutputStream(propertyFile);
if (StringUtils.isNotBlank(headerText)) {
props.store(out, headerText);
}
} catch (FileNotFoundException ex) {
LOG.warn("Failed to find properties file", ex);
} catch (IOException ex) {
LOG.warn("Failed to read properties file", ex);
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException ex) {
LOG.warn("Failed to close properties file", ex);
}
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
* Copyright (c) 2004-2014 Stuart Boston
*
* This file is part of TheMovieDB API.
*
@@ -67,6 +67,9 @@ import com.omertron.themoviedbapi.model.Trailer;
import com.omertron.themoviedbapi.model.Translation;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap;
import java.io.File;
import java.util.Properties;
import org.apache.commons.lang3.math.NumberUtils;
/**
* Test cases for TheMovieDbApi API
@@ -78,7 +81,10 @@ public class TheMovieDbApiTest {
// Logger
private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApiTest.class);
// API Key
private static final String API_KEY = "5a1a77e2eba8984804586122754f969f";
private static final String PROP_FIlENAME = "testing.properties";
private static String API_KEY;
private static int ACCOUNT_ID_APITESTS;
private static String SESSION_ID_APITESTS;
private static TheMovieDbApi tmdb;
// Test data
private static final int ID_MOVIE_BLADE_RUNNER = 78;
@@ -94,16 +100,35 @@ public class TheMovieDbApiTest {
private static final String LANGUAGE_ENGLISH = "en";
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 {
}
@BeforeClass
public static void setUpClass() throws Exception {
tmdb = new TheMovieDbApi(API_KEY);
TestLogger.Configure();
Properties props = new Properties();
File f = new File(PROP_FIlENAME);
if (f.exists()) {
LOG.info("Loading properties from '{}'", PROP_FIlENAME);
TestLogger.loadProperties(props, f);
API_KEY = props.getProperty("API_Key");
ACCOUNT_ID_APITESTS = NumberUtils.toInt(props.getProperty("Account_ID"), 0);
SESSION_ID_APITESTS = props.getProperty("Session_ID");
} else {
LOG.info("Property file '{}' not found, creating dummy file.", PROP_FIlENAME);
props.setProperty("API_Key", "INSERT_YOUR_KEY_HERE");
props.setProperty("Account_ID", "ACCOUNT ID FOR SESSION TESTS");
props.setProperty("Session_ID", "INSERT_YOUR_SESSION_ID_HERE");
TestLogger.saveProperties(props, f, "Properties file for tests");
fail("Failed to get key information from properties file '" + PROP_FIlENAME + "'");
}
tmdb = new TheMovieDbApi(API_KEY);
}
@AfterClass
@@ -136,11 +161,12 @@ public class TheMovieDbApiTest {
@Test
public void testAccount() throws MovieDbException {
LOG.info("Using Session ID '{}' for test", SESSION_ID_APITESTS);
Account account = tmdb.getAccount(SESSION_ID_APITESTS);
// Make sure properties are extracted correctly
assertEquals(account.getUserName(), "apitests");
assertEquals(account.getId(), ACCOUNT_ID_APITESTS);
assertEquals("apitests", account.getUserName());
assertEquals(ACCOUNT_ID_APITESTS, account.getId());
}
@Ignore("Session required")
+5
View File
@@ -0,0 +1,5 @@
#Properties file for tests
#Fill in the details here
Session_ID=INSERT_YOUR_SESSION_ID_HERE
Account_ID=ACCOUNT ID FOR SESSION TESTS
API_Key=INSERT_YOUR_KEY_HERE