Abstract some duplicate code

master
Stuart Boston 11 years ago
parent d5fc5e279d
commit 75c9142385

@ -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;
}
}

@ -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.
}

@ -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.
}

@ -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.
}

Loading…
Cancel
Save