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 * The Class Environment.
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 /*** The id. */
32 private Long id;
33
34 /*** The name. */
35 private String name;
36
37 /*** The agents. */
38 private Set<Agent> agents = new HashSet<Agent>();
39
40 /***
41 * Instantiates a new environment.
42 */
43 public Environment() {
44 }
45
46
47
48
49
50
51 @Override
52 @Id
53 @GeneratedValue(strategy = GenerationType.AUTO)
54 public Long getId() {
55 return this.id;
56 }
57
58 /***
59 * Sets the id.
60 *
61 * @param id the new id
62 */
63 public void setId(Long id) {
64 this.id = id;
65 }
66
67 /***
68 * Gets the name.
69 *
70 * @return the name
71 */
72 public String getName() {
73 return name;
74 }
75
76 /***
77 * Sets the name.
78 *
79 * @param name the new name
80 */
81 public void setName(String name) {
82 this.name = name;
83 }
84
85 /***
86 * Gets the agents.
87 *
88 * @return the agents
89 */
90 @ManyToMany(fetch = FetchType.LAZY)
91 public Set<Agent> getAgents() {
92 return agents;
93 }
94
95 /***
96 * Sets the agents.
97 *
98 * @param agents the new agents
99 */
100 public void setAgents(Set<Agent> agents) {
101 this.agents = agents;
102 }
103
104
105
106
107
108
109 @Override
110 public int hashCode() {
111 final int prime = 31;
112 int result = 1;
113 result = prime * result + ((id == null) ? 0 : id.hashCode());
114 result = prime * result + ((name == null) ? 0 : name.hashCode());
115 return result;
116 }
117
118
119
120
121
122
123 @Override
124 public boolean equals(Object obj) {
125 if (this == obj)
126 return true;
127 if (obj == null)
128 return false;
129 if (getClass() != obj.getClass())
130 return false;
131 final Environment other = (Environment) obj;
132 if (id == null) {
133 if (other.id != null)
134 return false;
135 } else if (!id.equals(other.id))
136 return false;
137 if (name == null) {
138 if (other.name != null)
139 return false;
140 } else if (!name.equals(other.name))
141 return false;
142 return true;
143 }
144 }