org.example.jpadomain.Contact Maven / Gradle / Ivy
The newest version!
package org.example.jpadomain;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* A domain object example. In a real application this would probably be a JPA
* entity or DTO.
*/
@Entity
public class Contact extends AbstractEntity {
@NotNull(message = "Name is required")
@Size(min = 3, max = 40, message = "name must be longer than 3 and less than 40 characters")
private String name;
@Size(max = 25, message = "Only 25 characters allowed")
private String phone;
@NotNull(message = "Email is required")
@Pattern(regexp = ".+@.+\\.[a-z]+", message = "Must be valid email")
private String email;
@ManyToOne
@NotNull(message = "Company is required")
private Company company;
public Contact(String name, String number, String email, Company company) {
this.name = name;
this.phone = number;
this.email = email;
this.company = company;
}
public Contact() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Company getCompany() {
return company;
}
public void setCompany(Company company) {
this.company = company;
}
@Override
public String toString() {
return "Contact{" + "name=" + name + ", number=" + phone + ", email=" + email + ", company=" + company + '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy