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