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.tasks;
18  
19  import static javax.persistence.GenerationType.IDENTITY;
20  
21  import javax.persistence.*;
22  import java.io.Serializable;
23  
24  /**
25   * User's task entity
26   * 
27   * @author Oliver Kiss
28   */
29  @SuppressWarnings("serial")
30  @Entity
31  public class Task implements Serializable {
32  
33      @Id
34      @GeneratedValue(strategy = IDENTITY)
35      private Long id;
36  
37      @ManyToOne
38      private User owner;
39  
40      private String title;
41  
42      public Task() {
43      }
44  
45      public Task(String title) {
46          super();
47          this.title = title;
48      }
49  
50      public Long getId() {
51          return id;
52      }
53  
54      public void setId(Long id) {
55          this.id = id;
56      }
57  
58      public User getOwner() {
59          return owner;
60      }
61  
62      public void setOwner(User owner) {
63          this.owner = owner;
64      }
65  
66      public String getTitle() {
67          return title;
68      }
69  
70      public void setTitle(String title) {
71          this.title = title;
72      }
73  
74      @Override
75      public int hashCode() {
76          final int prime = 31;
77          int result = 1;
78          result = prime * result + ((owner == null) ? 0 : owner.hashCode());
79          result = prime * result + ((title == null) ? 0 : title.hashCode());
80          return result;
81      }
82  
83      @Override
84      public boolean equals(Object obj) {
85          if (this == obj)
86              return true;
87          if (obj == null)
88              return false;
89          if (getClass() != obj.getClass())
90              return false;
91          Task other = (Task) obj;
92          if (owner == null) {
93              if (other.owner != null)
94                  return false;
95          } else if (!owner.equals(other.owner))
96              return false;
97          if (title == null) {
98              if (other.title != null)
99                  return false;
100         } else if (!title.equals(other.title))
101             return false;
102         return true;
103     }
104 
105 }