1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.jboss.as.quickstarts.tasksJsf;
18
19 import static javax.persistence.GenerationType.IDENTITY;
20
21 import java.io.Serializable;
22
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.Id;
26 import javax.persistence.ManyToOne;
27
28
29
30
31
32
33 @SuppressWarnings("serial")
34 @Entity
35 public class Task implements Serializable {
36
37 @Id
38 @GeneratedValue(strategy = IDENTITY)
39 private Long id;
40
41 @ManyToOne
42 private User owner;
43
44 private String title;
45
46 public Task() {
47 }
48
49 public Task(String title) {
50 super();
51 this.title = title;
52 }
53
54 public Long getId() {
55 return id;
56 }
57
58 public void setId(Long id) {
59 this.id = id;
60 }
61
62 public User getOwner() {
63 return owner;
64 }
65
66 public void setOwner(User owner) {
67 this.owner = owner;
68 }
69
70 public String getTitle() {
71 return title;
72 }
73
74 public void setTitle(String title) {
75 this.title = title;
76 }
77
78 @Override
79 public int hashCode() {
80 final int prime = 31;
81 int result = 1;
82 result = prime * result + ((owner == null) ? 0 : owner.hashCode());
83 result = prime * result + ((title == null) ? 0 : title.hashCode());
84 return result;
85 }
86
87 @Override
88 public boolean equals(Object obj) {
89 if (this == obj) {
90 return true;
91 }
92 if (obj == null) {
93 return false;
94 }
95 if (getClass() != obj.getClass()) {
96 return false;
97 }
98 Task other = (Task) obj;
99 if (owner == null) {
100 if (other.owner != null) {
101 return false;
102 }
103 } else if (!owner.equals(other.owner)) {
104 return false;
105 }
106 if (title == null) {
107 if (other.title != null) {
108 return false;
109 }
110 } else if (!title.equals(other.title)) {
111 return false;
112 }
113 return true;
114 }
115
116 }