package com.sap.pto.dao.entities;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.eclipse.persistence.annotations.Index;
@Table(name = "Players")
@Entity
public class Player extends BasicEntity {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private long id;
@Index
private String extId;
@Index
private Team team;
private String firstName;
private String lastName;
private String nickName;
private String country;
private String position;
private String positionSide;
private String birthday;
private String dateJoined;
private int jerseyNumber;
private int weight;
private int height;
@Transient
private List<PlayerStat> statistics = new ArrayList<PlayerStat>();
public Player() {
// just needed for JPA
}
public Player(String extId) {
this.extId = extId;
}
public String getExtId() {
return extId;
}
public void setExtId(String extId) {
this.extId = extId;
}
public Team getTeam() {
return team;
}
public void setTeam(Team team) {
this.team = team;
}
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;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getPositionSide() {
return positionSide;
}
public void setPositionSide(String positionSide) {
this.positionSide = positionSide;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getDateJoined() {
return dateJoined;
}
public void setDateJoined(String dateJoined) {
this.dateJoined = dateJoined;
}
public int getJerseyNumber() {
return jerseyNumber;
}
public void setJerseyNumber(int jerseyNumber) {
this.jerseyNumber = jerseyNumber;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public long getId() {
return id;
}
public List<PlayerStat> getStatistics() {
return statistics;
}
public void setStatistics(List<PlayerStat> statistics) {
this.statistics = statistics;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((birthday == null) ? 0 : birthday.hashCode());
result = prime * result + ((country == null) ? 0 : country.hashCode());
result = prime * result + ((dateJoined == null) ? 0 : dateJoined.hashCode());
result = prime * result + ((extId == null) ? 0 : extId.hashCode());
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result + height;
result = prime * result + jerseyNumber;
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
result = prime * result + ((nickName == null) ? 0 : nickName.hashCode());
result = prime * result + ((position == null) ? 0 : position.hashCode());
result = prime * result + ((positionSide == null) ? 0 : positionSide.hashCode());
result = prime * result + ((team == null) ? 0 : team.hashCode());
result = prime * result + weight;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Player other = (Player) obj;
if (birthday == null) {
if (other.birthday != null)
return false;
} else if (!birthday.equals(other.birthday))
return false;
if (country == null) {
if (other.country != null)
return false;
} else if (!country.equals(other.country))
return false;
if (dateJoined == null) {
if (other.dateJoined != null)
return false;
} else if (!dateJoined.equals(other.dateJoined))
return false;
if (extId == null) {
if (other.extId != null)
return false;
} else if (!extId.equals(other.extId))
return false;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (height != other.height)
return false;
if (jerseyNumber != other.jerseyNumber)
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
if (nickName == null) {
if (other.nickName != null)
return false;
} else if (!nickName.equals(other.nickName))
return false;
if (position == null) {
if (other.position != null)
return false;
} else if (!position.equals(other.position))
return false;
if (positionSide == null) {
if (other.positionSide != null)
return false;
} else if (!positionSide.equals(other.positionSide))
return false;
if (team == null) {
if (other.team != null)
return false;
} else if (!team.equals(other.team))
return false;
if (weight != other.weight)
return false;
return true;
}
@Override
public String toString() {
return "Player [firstName=" + firstName + ", lastName=" + lastName + "]";
}
}