package com.captechconsulting.core.domain;
import com.google.common.collect.Lists;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@Entity
public class Ticket {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstName;
private String lastName;
@NotNull
@OneToOne(cascade = CascadeType.ALL)
private Address address;
// As of version 2
@Column
private String email;
@Column
private String phoneNumber;
@NotNull
@Column(nullable = false)
private String packageNumber;
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
private List<LocationScan> locationScans = Lists.newArrayList();
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;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getPackageNumber() {
return packageNumber;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public void setPackageNumber(String packageNumber) {
this.packageNumber = packageNumber;
}
public List<LocationScan> getLocationScans() {
return locationScans;
}
public void setLocationScans(List<LocationScan> locationScans) {
this.locationScans = locationScans;
}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}