1 package org.objectweb.rentacar.persistance.bo; 2 3 import java.util.HashSet ; 4 import java.util.Set ; 5 6 import org.apache.commons.lang.builder.EqualsBuilder; 7 import org.apache.commons.lang.builder.HashCodeBuilder; 8 import org.apache.commons.lang.builder.ToStringBuilder; 9 10 15 public class CentralOfficeVO { 16 17 private String centralOfficeId; 18 19 private String host; 20 21 private String port; 22 23 private Set <String > agencies; 24 25 public CentralOfficeVO() { 26 super(); 27 } 29 30 public CentralOfficeVO(Set <String > agencies) { 31 super(); 32 this.agencies = agencies; 33 } 34 35 public CentralOfficeVO(String centralOfficeId, Set <String > agencies) { 36 super(); 37 this.centralOfficeId = centralOfficeId; 39 this.agencies = agencies; 40 } 41 42 public CentralOfficeVO(CentralOffice centralOffice) { 43 super(); 44 this.centralOfficeId = centralOffice.getCentralOfficeId(); 45 Set <String > agencies = new HashSet <String >(); 46 for (Agency agency : centralOffice.getAgencies()) { 47 agencies.add(agency.getAgencyId()); 48 } 49 this.agencies = agencies; 50 this.host = centralOffice.getHost(); 51 this.port = centralOffice.getPort(); 52 } 53 54 public Set <String > getAgencies() { 55 return agencies; 56 } 57 58 public void setAgencies(Set <String > agencies) { 59 this.agencies = agencies; 60 } 61 62 public String getCentralOfficeId() { 63 return centralOfficeId; 64 } 65 66 public void setCentralOfficeId(String centralOfficeId) { 67 this.centralOfficeId = centralOfficeId; 68 } 69 70 public String getHost() { 71 return host; 72 } 73 74 public void setHost(String host) { 75 this.host = host; 76 } 77 78 public String getPort() { 79 return port; 80 } 81 82 public void setPort(String port) { 83 this.port = port; 84 } 85 86 89 public boolean equals(Object object) { 90 if (!(object instanceof CentralOfficeVO)) { 91 return false; 92 } 93 CentralOfficeVO rhs = (CentralOfficeVO) object; 94 return new EqualsBuilder().append(this.centralOfficeId, 95 rhs.centralOfficeId).append(this.host, rhs.host).append( 96 this.agencies, rhs.agencies).append(this.port, rhs.port) 97 .isEquals(); 98 } 99 100 103 public int hashCode() { 104 return new HashCodeBuilder(-1002924675, -292380135).append( 105 this.centralOfficeId).append(this.host).append(this.agencies) 106 .append(this.port).toHashCode(); 107 } 108 109 112 public String toString() { 113 return new ToStringBuilder(this).append("centralOfficeId", 114 this.centralOfficeId).append("agencies", this.agencies).append( 115 "host", this.host).append("port", this.port).toString(); 116 } 117 118 119 120 } 121 | Popular Tags |