package de.gedoplan.seminar.jpa.exercise.domain;
|
|
import java.util.Objects;
|
|
import javax.persistence.Entity;
|
import javax.persistence.EnumType;
|
import javax.persistence.Enumerated;
|
import javax.persistence.GeneratedValue;
|
import javax.persistence.GenerationType;
|
import javax.persistence.Id;
|
import javax.persistence.ManyToOne;
|
import javax.persistence.Table;
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
|
@Entity
|
@Table(name = Junction.TABLE_NAME)
|
public class Junction {
|
|
public static final String TABLE_NAME = "JPA_JUNCTION";
|
|
@Id
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
private Integer id;
|
|
private String name;
|
|
@Enumerated(EnumType.STRING)
|
private JunctionKind kind;
|
|
private String no;
|
|
@JsonIgnoreProperties("junctions")
|
@ManyToOne
|
private Highway highway;
|
|
public Junction() {
|
|
}
|
|
public Junction(String name, JunctionKind kind, String no) {
|
this.name = name;
|
this.kind = kind;
|
this.no = no;
|
}
|
|
public Integer getId() {
|
return id;
|
}
|
|
public void setId(Integer id) {
|
this.id = id;
|
}
|
|
public String getName() {
|
return name;
|
}
|
|
public void setName(String name) {
|
this.name = name;
|
}
|
|
public JunctionKind getKind() {
|
return kind;
|
}
|
|
public void setKind(JunctionKind kind) {
|
this.kind = kind;
|
}
|
|
public String getNo() {
|
return no;
|
}
|
|
public void setNo(String no) {
|
this.no = no;
|
}
|
|
|
public Highway getHighway() {
|
return highway;
|
}
|
|
public void setHighway(Highway highway) {
|
this.highway = highway;
|
}
|
|
@Override
|
public int hashCode() {
|
return Objects.hash(id);
|
}
|
|
@Override
|
public boolean equals(Object obj) {
|
if (this == obj)
|
return true;
|
if (obj == null)
|
return false;
|
if (getClass() != obj.getClass())
|
return false;
|
Junction other = (Junction) obj;
|
return Objects.equals(id, other.id);
|
}
|
|
@Override
|
public String toString() {
|
return "Junction [id=" + id + ", name=" + name + ", kind=" + kind + ", no=" + no + "]";
|
}
|
|
}
|