Ravi Srinivasan
2018-09-11 b9209f6413cb6985c0089f9677f4db9b52ca1395
commit | author | age
b9209f 1 package com.redhat.training.model;
RS 2
3 import javax.persistence.Entity;
4 import javax.persistence.GeneratedValue;
5 import javax.persistence.GenerationType;
6 import javax.persistence.Id;
7 import javax.validation.constraints.NotNull;
8 import javax.validation.constraints.Size;
9
10 @Entity
11 public class Person {
12     @Id
13     @GeneratedValue(strategy = GenerationType.IDENTITY)
14     private Long id;
15
16     @NotNull
17     @Size(min=2,max=50)
18     private String name;
19
20     public Long getId() {
21         return id;
22     }
23
24     public void setId(Long id) {
25         this.id = id;
26     }
27
28     public String getName() {
29         return name;
30     }
31
32     public void setName(String name) {
33         this.name = name;
34     }
35
36     @Override
37     public int hashCode() {
38         final int prime = 31;
39         int result = 1;
40         result = prime * result + ((id == null) ? 0 : id.hashCode());
41         return result;
42     }
43
44     @Override
45     public boolean equals(Object obj) {
46         if (this == obj)
47             return true;
48         if (obj == null)
49             return false;
50         if (getClass() != obj.getClass())
51             return false;
52         Person other = (Person) obj;
53         if (id == null) {
54             if (other.id != null)
55                 return false;
56         } else if (!id.equals(other.id))
57             return false;
58         return true;
59     }
60
61     
62 }