diff --git a/src/main/java/com/omertron/themoviedbapi/model/AbstractIdName.java b/src/main/java/com/omertron/themoviedbapi/model/AbstractIdName.java new file mode 100644 index 000000000..7da96057a --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/AbstractIdName.java @@ -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; + +/** + * + * @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(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AbstractIdName other = (AbstractIdName) obj; + if (this.id != other.id) { + return false; + } + return !(this.name == null ? other.name != null : !this.name.equals(other.name)); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 37 * hash + this.id; + hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java index d9bcdf3b2..371dec7d2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -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. } diff --git a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java index be4dd599f..b6648d743 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -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. } diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index 8885a6082..cec93322b 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -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. }