Skip to content

Instantly share code, notes, and snippets.

@JosePaumard
Created January 12, 2017 08:42
Show Gist options
  • Save JosePaumard/94ea2bc3f76cf26afa4614c6fe9902e6 to your computer and use it in GitHub Desktop.
Save JosePaumard/94ea2bc3f76cf26afa4614c6fe9902e6 to your computer and use it in GitHub Desktop.
package org.paumard.movies.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Actor {
@XmlAttribute
private long id;
@XmlElement(name="first-name")
private String firstName;
@XmlElement(name="last-name")
private String lastName;
public static Actor of(long id, String firstName, String lastName) {
Actor actor = new Actor();
actor.id = id;
actor.firstName = firstName;
actor.lastName = firstName;
return actor;
}
public static Actor of(String firstName, String lastName) {
Actor actor = new Actor();
actor.firstName = firstName;
actor.lastName = lastName;
return actor;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return "Actor [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Actor other = (Actor) obj;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment