Refactorings for RedeBayesiana and ArquivoRedeBayesiana.
[simdecs_seam.git] / SimDeCS / src / main / org / ufcspa / simdecs / entities / PerguntaNodo.java
1 package org.ufcspa.simdecs.entities;
2
3 import java.io.Serializable;
4
5 import javax.persistence.Column;
6 import javax.persistence.Entity;
7 import javax.persistence.GeneratedValue;
8 import javax.persistence.GenerationType;
9 import javax.persistence.Id;
10 import javax.persistence.JoinColumn;
11 import javax.persistence.ManyToOne;
12 import javax.persistence.SequenceGenerator;
13 import javax.persistence.Table;
14
15 import org.hibernate.annotations.Index;
16
17
18 @Entity
19 @Table(name="PerguntaNodo")
20 @SequenceGenerator(name = "sequencePerguntaNodo", sequenceName = "sqPerguntaNodo", initialValue = 1, allocationSize=1)
21 public class PerguntaNodo implements Serializable {
22
23         private static final long serialVersionUID = 6879782331178330999L;
24
25         @Id
26         @GeneratedValue(generator="sequencePerguntaNodo", strategy=GenerationType.AUTO)
27         private Long id;
28
29         @Column(length=100, nullable=false)
30         private String texto;
31         
32     @ManyToOne
33     @JoinColumn(name = "nodo_id", referencedColumnName = "id", nullable = true)
34     @Index(name="pergunta_nodo_fk_i")
35         private Nodo nodo;
36     
37         public Long getId() {
38                 return id;
39         }
40         public void setId(Long id) {
41                 this.id = id;
42         }
43         public String getTexto() {
44                 return texto;
45         }
46         public void setTexto(String pergunta) {
47                 this.texto = pergunta;
48         }
49
50         public Nodo getNodo() {
51                 return nodo;
52         }
53
54         public void getNodo(Nodo nodo) {
55                 this.nodo = nodo;
56         }
57         
58         public String toString() {
59                 return id + " - " + texto;
60         }
61
62         @Override
63         public int hashCode() {
64                 final int prime = 31;
65                 int result = 1;
66                 result = prime * result + ((id == null) ? 0 : id.hashCode());
67                 return result;
68         }
69
70         @Override
71         public boolean equals(Object obj) {
72                 if (this == obj)
73                         return true;
74                 if (obj == null)
75                         return false;
76                 if (getClass() != obj.getClass())
77                         return false;
78                 PerguntaNodo other = (PerguntaNodo) obj;
79                 if (id == null) {
80                         if (other.id != null)
81                                 return false;
82                 } else if (!id.equals(other.id))
83                         return false;
84                 return true;
85         }
86         
87         public PerguntaNodo() {
88                 
89         }
90 }