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.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   * User's task entity
30   *
31   * @author Oliver Kiss
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 }