KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > validator > test > Address


1 //$Id: Address.java,v 1.1 2005/05/27 08:58:54 epbernard Exp $
2
package org.hibernate.validator.test;
3
4 import javax.persistence.Entity;
5 import javax.persistence.Id;
6 import javax.persistence.Transient;
7
8 import org.hibernate.validator.AssertTrue;
9 import org.hibernate.validator.Length;
10 import org.hibernate.validator.Min;
11 import org.hibernate.validator.NotNull;
12 import org.hibernate.validator.Pattern;
13 import org.hibernate.validator.Range;
14
15 /**
16  * @author Gavin King
17  */

18 @Entity
19 public class Address {
20     private String JavaDoc line1;
21     private String JavaDoc line2;
22     private String JavaDoc zip;
23     private String JavaDoc state;
24     private String JavaDoc country;
25     private long id;
26     
27     @Length(max=20)
28     @NotNull
29     public String JavaDoc getCountry() {
30         return country;
31     }
32     
33     public void setCountry(String JavaDoc country) {
34         this.country = country;
35     }
36     
37     @NotNull
38     public String JavaDoc getLine1() {
39         return line1;
40     }
41     
42     public void setLine1(String JavaDoc line1) {
43         this.line1 = line1;
44     }
45     
46     public String JavaDoc getLine2() {
47         return line2;
48     }
49     
50     public void setLine2(String JavaDoc line2) {
51         this.line2 = line2;
52     }
53     
54     @Length(max=3) @NotNull
55     public String JavaDoc getState() {
56         return state;
57     }
58     
59     public void setState(String JavaDoc state) {
60         this.state = state;
61     }
62     
63     @Length(max=5, message="{long}")
64     @Pattern(regex="[0-9]+")
65     @NotNull
66     public String JavaDoc getZip() {
67         return zip;
68     }
69     
70     public void setZip(String JavaDoc zip) {
71         this.zip = zip;
72     }
73     
74     @AssertTrue
75     @Transient
76     public boolean isValid() {
77         return true;
78     }
79
80     @Id @Min(1)
81     @Range(max=2000)
82     public long getId() {
83         return id;
84     }
85
86     public void setId(long id) {
87         this.id = id;
88     }
89     
90 }
91
Popular Tags