Commit | Line | Data |
---|---|---|
5d05ee58 MS |
1 | /* |
2 | * To change this template, choose Tools | Templates | |
3 | * and open the template in the editor. | |
4 | */ | |
5 | package org.ufcspa.simdecs.bn.entity; | |
6 | ||
7 | import java.io.Serializable; | |
8 | import java.util.List; | |
9 | import javax.persistence.*; | |
10 | ||
11 | /** | |
12 | * | |
13 | * @author mchelem | |
14 | */ | |
15 | @Entity | |
16 | public class BayesianNetwork implements Serializable { | |
17 | private static final long serialVersionUID = 1L; | |
18 | @Id | |
19 | @GeneratedValue(strategy = GenerationType.AUTO) | |
20 | private Long id; | |
21 | ||
22 | private String name; | |
23 | ||
24 | @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy = "bayesianNetwork") | |
25 | private List<Node> nodes; | |
26 | ||
27 | public Long getId() { | |
28 | return id; | |
29 | } | |
30 | ||
31 | public void setId(Long id) { | |
32 | this.id = id; | |
33 | } | |
34 | ||
35 | public String getName() { | |
36 | return name; | |
37 | } | |
38 | ||
39 | public void setName(String name) { | |
40 | this.name = name; | |
41 | } | |
42 | ||
43 | public List<Node> getNodes() { | |
44 | return nodes; | |
45 | } | |
46 | ||
47 | public void setNodes(List<Node> nodes) { | |
48 | this.nodes = nodes; | |
49 | } | |
50 | ||
51 | @Override | |
52 | public int hashCode() { | |
53 | int hash = 0; | |
54 | hash += (id != null ? id.hashCode() : 0); | |
55 | return hash; | |
56 | } | |
57 | ||
58 | @Override | |
59 | public boolean equals(Object object) { | |
60 | // TODO: Warning - this method won't work in the case the id fields are not set | |
61 | if (!(object instanceof BayesianNetwork)) { | |
62 | return false; | |
63 | } | |
64 | BayesianNetwork other = (BayesianNetwork) object; | |
65 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { | |
66 | return false; | |
67 | } | |
68 | return true; | |
69 | } | |
70 | ||
71 | @Override | |
72 | public String toString() { | |
73 | return name; | |
74 | } | |
75 | ||
76 | } |