1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
package org.directdemocracyportal.democracy.model.core; |
6 | |
|
7 | |
import java.util.HashSet; |
8 | |
import java.util.Set; |
9 | |
|
10 | |
import javax.persistence.Entity; |
11 | |
import javax.persistence.FetchType; |
12 | |
import javax.persistence.GeneratedValue; |
13 | |
import javax.persistence.GenerationType; |
14 | |
import javax.persistence.Id; |
15 | |
import javax.persistence.Inheritance; |
16 | |
import javax.persistence.InheritanceType; |
17 | |
import javax.persistence.ManyToMany; |
18 | |
|
19 | |
import org.hibernate.annotations.Cache; |
20 | |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
@Entity |
26 | |
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) |
27 | |
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) |
28 | |
public abstract class Environment extends BaseEntity |
29 | |
{ |
30 | |
|
31 | |
|
32 | |
private Long id; |
33 | |
|
34 | |
|
35 | |
private String name; |
36 | |
|
37 | |
|
38 | 3 | private Set<Agent> agents = new HashSet<Agent>(); |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 3 | public Environment() { |
44 | 3 | } |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
@Override |
52 | |
@Id |
53 | |
@GeneratedValue(strategy = GenerationType.AUTO) |
54 | |
public Long getId() { |
55 | 3 | return this.id; |
56 | |
} |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public void setId(Long id) { |
64 | 0 | this.id = id; |
65 | 0 | } |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public String getName() { |
73 | 0 | return name; |
74 | |
} |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public void setName(String name) { |
82 | 0 | this.name = name; |
83 | 0 | } |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
@ManyToMany(fetch = FetchType.LAZY) |
91 | |
public Set<Agent> getAgents() { |
92 | 0 | return agents; |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public void setAgents(Set<Agent> agents) { |
101 | 0 | this.agents = agents; |
102 | 0 | } |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
@Override |
110 | |
public int hashCode() { |
111 | |
final int prime = 31; |
112 | 0 | int result = 1; |
113 | 0 | result = prime * result + ((id == null) ? 0 : id.hashCode()); |
114 | 0 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
115 | 0 | return result; |
116 | |
} |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
@Override |
124 | |
public boolean equals(Object obj) { |
125 | 0 | if (this == obj) |
126 | 0 | return true; |
127 | 0 | if (obj == null) |
128 | 0 | return false; |
129 | 0 | if (getClass() != obj.getClass()) |
130 | 0 | return false; |
131 | 0 | final Environment other = (Environment) obj; |
132 | 0 | if (id == null) { |
133 | 0 | if (other.id != null) |
134 | 0 | return false; |
135 | 0 | } else if (!id.equals(other.id)) |
136 | 0 | return false; |
137 | 0 | if (name == null) { |
138 | 0 | if (other.name != null) |
139 | 0 | return false; |
140 | 0 | } else if (!name.equals(other.name)) |
141 | 0 | return false; |
142 | 0 | return true; |
143 | |
} |
144 | |
} |