1 package info.ejava.examples.ejb.interceptor.bo; 2 3 import javax.persistence.Column; 4 import javax.persistence.Entity; 5 import javax.persistence.Table; 6 import javax.validation.constraints.NotNull; 7 import javax.validation.constraints.Pattern; 8 import javax.validation.constraints.Size; 9 10 @SuppressWarnings("serial") 11 @Entity 12 @Table(name="EJBINTERCEPTOR_PHONEINFO") 13 public class PhoneInfo extends ContactInfo { 14 @NotNull(groups={PreNormalizedCheck.class, PrePersistCheck.class}) 15 @Size(min=12, max=12, groups=PostNormalizedCheck.class) 16 @Pattern.List({ 17 @Pattern(regexp="^[0-9-]+$", groups=PreNormalizedCheck.class), 18 @Pattern(regexp="^[0-9]{3}-[0-9]{3}-[0-9]{4}$", groups=PostNormalizedCheck.class) 19 }) 20 @Column(name="PHONE_NUMBER", nullable=false, length=12) 21 private String phoneNumber; 22 23 @Column(name="EXTENSION") 24 private Integer extension; 25 26 @Override 27 public ContactType getContactType() { 28 return ContactType.PHONE; 29 } 30 31 public String getPhoneNumber() { return phoneNumber; } 32 public void setPhoneNumber(String phoneNumber) { 33 this.phoneNumber = phoneNumber; 34 } 35 36 public Integer getExtension() { return extension; } 37 public void setExtension(Integer extension) { 38 this.extension = extension; 39 } 40 41 @Override 42 public String toString() { 43 StringBuilder builder = new StringBuilder(); 44 builder.append("PhoneInfo [") 45 .append("getRole()=").append(getRole()) 46 .append(", number=").append(phoneNumber) 47 .append(", ext=").append(extension) 48 .append("]"); 49 return builder.toString(); 50 } 51 }