1 package org.objectweb.rentacar.persistance.bo; 2 3 import java.util.Date ; 4 import java.util.HashSet ; 5 import java.util.Set ; 6 7 import org.apache.commons.lang.builder.EqualsBuilder; 8 import org.apache.commons.lang.builder.HashCodeBuilder; 9 import org.apache.commons.lang.builder.ToStringBuilder; 10 11 16 public class ReservationVO { 17 18 private String reservationId; 19 20 private ContactVO customer; 21 22 private Set <CarVO> cars; 23 24 private Date startingDate; 25 26 private Date endingDate; 27 28 private AgencyVO startingAgency; 29 30 private AgencyVO endingAgency; 31 32 33 34 public ReservationVO() { 35 super(); 36 } 37 38 public ReservationVO(ContactVO customer, Set <CarVO> cars, Date startingDate, Date endingDate, AgencyVO startingAgency, AgencyVO endingAgency) { 39 super(); 40 this.customer = customer; 41 this.cars = cars; 42 this.startingDate = startingDate; 43 this.endingDate = endingDate; 44 this.startingAgency = startingAgency; 45 this.endingAgency = endingAgency; 46 } 47 48 public ReservationVO(String reservationId, ContactVO customer, Set <CarVO> cars, Date startingDate, Date endingDate, AgencyVO startingAgency, AgencyVO endingAgency) { 49 super(); 50 this.reservationId = reservationId; 51 this.customer = customer; 52 this.cars = cars; 53 this.startingDate = startingDate; 54 this.endingDate = endingDate; 55 this.startingAgency = startingAgency; 56 this.endingAgency = endingAgency; 57 } 58 59 public ReservationVO(Reservation reservation) { 60 super(); 61 this.reservationId = reservation.getReservationId(); 62 this.customer = new ContactVO(reservation.getCustomer()); 63 Set <CarVO> cars = new HashSet <CarVO>(); 64 for (Car car : reservation.getCars()) { 65 cars.add(new CarVO(car)); 66 } 67 this.cars = cars; 68 this.startingDate = reservation.getStartingDate(); 69 this.endingDate = reservation.getEndingDate(); 70 this.startingAgency = new AgencyVO(reservation.getStartingAgency()); 71 this.endingAgency = new AgencyVO(reservation.getEndingAgency()); 72 } 73 74 public Set <CarVO> getCars() { 75 return cars; 76 } 77 78 public void setCars(Set <CarVO> cars) { 79 this.cars = cars; 80 } 81 82 public ContactVO getCustomer() { 83 return customer; 84 } 85 86 public void setCustomer(ContactVO customer) { 87 this.customer = customer; 88 } 89 90 public AgencyVO getEndingAgency() { 91 return endingAgency; 92 } 93 94 public void setEndingAgency(AgencyVO endingAgency) { 95 this.endingAgency = endingAgency; 96 } 97 98 public Date getEndingDate() { 99 return endingDate; 100 } 101 102 public void setEndingDate(Date endingDate) { 103 this.endingDate = endingDate; 104 } 105 106 public String getReservationId() { 107 return reservationId; 108 } 109 110 public void setReservationId(String reservationId) { 111 this.reservationId = reservationId; 112 } 113 114 public AgencyVO getStartingAgency() { 115 return startingAgency; 116 } 117 118 public void setStartingAgency(AgencyVO startingAgency) { 119 this.startingAgency = startingAgency; 120 } 121 122 public Date getStartingDate() { 123 return startingDate; 124 } 125 126 public void setStartingDate(Date startingDate) { 127 this.startingDate = startingDate; 128 } 129 130 133 public boolean equals(Object object) { 134 if (!(object instanceof ReservationVO)) { 135 return false; 136 } 137 ReservationVO rhs = (ReservationVO) object; 138 return new EqualsBuilder().append(this.endingDate, rhs.endingDate) 139 .append(this.cars, rhs.cars).append(this.startingDate, rhs.startingDate).append( 140 this.reservationId, rhs.reservationId).append( 141 this.customer, rhs.customer).append(this.endingAgency, 142 rhs.endingAgency).append(this.startingAgency, 143 rhs.startingAgency).isEquals(); 144 } 145 146 149 public int hashCode() { 150 return new HashCodeBuilder(2130538209, 1222600301).append( 151 this.endingDate).append(this.cars).append( 152 this.startingDate).append(this.reservationId).append( 153 this.customer).append(this.endingAgency).append( 154 this.startingAgency).toHashCode(); 155 } 156 157 160 public String toString() { 161 return new ToStringBuilder(this).append("startingDate", 162 this.startingDate).append("car", this.cars).append( 163 "reservationId", this.reservationId).append("customer", 164 this.customer).append("startingAgency", this.startingAgency) 165 .append("endingAgency", 166 this.endingAgency) 167 .append("endingDate", this.endingDate).toString(); 168 } 169 170 } 171 | Popular Tags |