content: package com.masai.models;
  
  import javax.persistence.CascadeType;
  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.validation.constraints.NotNull;
  import javax.validation.constraints.Pattern;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  
  import lombok.AllArgsConstructor;
  import lombok.EqualsAndHashCode;
  import lombok.Getter;
  import lombok.NoArgsConstructor;
  import lombok.Setter;
  import lombok.ToString;
  
  @Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  @ToString
  @EqualsAndHashCode
  @Entity
  public class Address {
  	
  	@Id
  	@GeneratedValue(strategy = GenerationType.AUTO)
  	private Integer addressId;
  	
  	@Pattern(regexp = "[A-Za-z0-9\\s-]{3,}", message = "Not a valid street no")
  	private String streetNo;
  	
  	@Pattern(regexp = "[A-Za-z0-9\\s-]{3,}", message = "Not a valid building name")
  	private String buildingName;
  	
  	@NotNull
  	@Pattern(regexp = "[A-Za-z0-9\\s-]{3,}", message = "Not a valid locality name")
  	private String locality;
  	
  	@NotNull(message = "City name cannot be null")
  	@Pattern(regexp = "[A-Za-z\\s]{2,}", message = "Not a valid city name")
  	private String city;
  	
  	@NotNull(message = "State name cannot be null")
  	private String state;
  	
  	@NotNull(message = "Pincode cannot be null")
  	@Pattern(regexp = "[0-9]{6}", message = "Pincode not valid. Must be 6 digits")
  	private String pincode;
  	
  	
  	@ManyToOne(cascade = CascadeType.ALL)
  	@JsonIgnore
  	private Customer customer;
  	
  	
  }
  