01: package org.manentia.kasai;
02:
03: import java.sql.ResultSet;
04: import java.sql.SQLException;
05: import java.util.ArrayList;
06: import java.util.Collection;
07:
08: /**
09: *
10: * @author fpena
11: *
12: */
13: public class Operative {
14:
15: private String id;
16:
17: private int sequence;
18:
19: private String description;
20: private Collection roles;
21:
22: public Operative() {
23: roles = new ArrayList();
24: }
25:
26: public Operative(ResultSet rs) throws SQLException {
27: roles = new ArrayList();
28: id = rs.getString("id");
29: sequence = rs.getInt("sequence");
30: description = rs.getString("description");
31: }
32:
33: public String getId() {
34: return this .id;
35: }
36:
37: public void setId(String id) {
38: this .id = id;
39: }
40:
41: public int getSequence() {
42: return this .sequence;
43: }
44:
45: public void setSequence(int sequence) {
46: this .sequence = sequence;
47: }
48:
49: public String getDescription() {
50: return this .description;
51: }
52:
53: public void setDescription(String description) {
54: this .description = description;
55: }
56:
57: public Collection getRoles() {
58: return roles;
59: }
60:
61: public void setRoles(Collection roles) {
62: this .roles = roles;
63: }
64:
65: public void addRole(Role role) {
66: if (role != null) {
67: if (!roles.contains(role)) {
68: this .roles.add(role);
69: }
70: }
71: }
72:
73: public void removeRole(Role role) {
74: if (role != null) {
75: this .roles.remove(role);
76: }
77: }
78:
79: public boolean equals(java.lang.Object obj) {
80: boolean result = false;
81:
82: try {
83: if (obj instanceof Operative) {
84: if (((Operative) obj).getId().equals(this .id)) {
85: result = true;
86: }
87: }
88: } catch (Exception e) {
89: result = false;
90: }
91: return result;
92: }
93:
94: }
|