com.github.tmdb.model.Collection Maven / Gradle / Ivy
package com.github.tmdb.model;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;
@JsonRootName("collection")
public class Collection {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(Collection.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("title")
private String title;
@JsonProperty("name")
private String name;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("backdrop_path")
private String backdropPath;
@JsonProperty("release_date")
private String releaseDate;
//
public String getBackdropPath() {
return backdropPath;
}
public int getId() {
return id;
}
public String getPosterPath() {
return posterPath;
}
public String getReleaseDate() {
return releaseDate;
}
public String getTitle() {
if (StringUtils.isBlank(title)) {
return name;
}
return title;
}
public String getName() {
if (StringUtils.isBlank(name)) {
return title;
}
return name;
}
//
//
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
}
public void setId(int id) {
this.id = id;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public void setTitle(String title) {
this.title = title;
}
public void setName(String name) {
this.name = name;
}
//
/**
* 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("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
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;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Collection=");
sb.append("[id=").append(id);
sb.append("],[title=").append(title);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("]]");
return sb.toString();
}
}