View Javadoc
1   /*
2    * JBoss, Home of Professional Open Source
3    * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
4    * contributors by the @authors tag. See the copyright.txt in the
5    * distribution for a full listing of individual contributors.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * http://www.apache.org/licenses/LICENSE-2.0
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.jboss.as.quickstarts.bean_validation.model;
18  
19  import java.io.Serializable;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.GeneratedValue;
24  import javax.persistence.Id;
25  import javax.persistence.Table;
26  import javax.validation.constraints.Digits;
27  import javax.validation.constraints.NotNull;
28  import javax.validation.constraints.Pattern;
29  import javax.validation.constraints.Size;
30  import javax.persistence.UniqueConstraint;
31  
32  import org.hibernate.validator.constraints.Email;
33  import org.hibernate.validator.constraints.NotEmpty;
34  
35  @Entity
36  @Table(name="MEMBER_BEAN_VALIDATION", uniqueConstraints = @UniqueConstraint(columnNames = "email"))
37  public class Member implements Serializable {
38      /** Default value included to remove warning. Remove or modify at will. **/
39      private static final long serialVersionUID = 1L;
40  
41      @Id
42      @GeneratedValue
43      private Long id;
44  
45      @NotNull
46      @Size(min = 1, max = 25)
47      @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
48      private String name;
49  
50      @NotNull
51      @NotEmpty
52      @Email
53      private String email;
54  
55      @NotNull
56      @Size(min = 10, max = 12)
57      @Digits(fraction = 0, integer = 12)
58      @Column(name = "phone_number")
59      private String phoneNumber;
60  
61      public Long getId() {
62          return id;
63      }
64  
65      public void setId(Long id) {
66          this.id = id;
67      }
68  
69      public String getName() {
70          return name;
71      }
72  
73      public void setName(String name) {
74          this.name = name;
75      }
76  
77      public String getEmail() {
78          return email;
79      }
80  
81      public void setEmail(String email) {
82          this.email = email;
83      }
84  
85      public String getPhoneNumber() {
86          return phoneNumber;
87      }
88  
89      public void setPhoneNumber(String phoneNumber) {
90          this.phoneNumber = phoneNumber;
91      }
92  }