1 package org.objectweb.rentacar.persistance.bo; 2 3 import javax.persistence.Entity; 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.Id; 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 import org.hibernate.annotations.GenericGenerator; 11 12 17 @Entity 18 public class Car { 19 20 private String carId; 22 23 private String type; 24 25 private String brand; 26 27 private String model; 28 29 public Car() { 30 super(); 31 } 33 34 public Car(String type, String brand, String model) { 35 super(); 36 this.type = type; 37 this.brand = brand; 38 this.model = model; 39 } 40 41 public Car(String carId, String type, String brand, String model) { 42 super(); 43 this.carId = carId; 45 this.type = type; 46 this.brand = brand; 47 this.model = model; 48 } 49 50 public Car(CarVO carVO) { 51 super(); 52 this.carId = carVO.getCarId(); 54 this.type = carVO.getType(); 55 this.brand = carVO.getBrand(); 56 this.model = carVO.getModel(); 57 } 58 59 public String getBrand() { 60 return brand; 61 } 62 63 public void setBrand(String brand) { 64 this.brand = brand; 65 } 66 67 @Id @GeneratedValue(generator = "system-uuid") 68 @GenericGenerator(name="system-uuid", strategy = "uuid") 69 public String getCarId() { 70 return carId; 71 } 72 73 public void setCarId(String carId) { 74 this.carId = carId; 75 } 76 77 public String getModel() { 78 return model; 79 } 80 81 public void setModel(String model) { 82 this.model = model; 83 } 84 85 public String getType() { 86 return type; 87 } 88 89 public void setType(String type) { 90 this.type = type; 91 } 92 93 96 public boolean equals(Object object) { 97 if (!(object instanceof Car)) { 98 return false; 99 } 100 Car rhs = (Car) object; 101 return new EqualsBuilder().append(this.brand, rhs.brand).append( 102 this.type, rhs.type).append( 103 this.model, rhs.model).append(this.carId, rhs.carId).isEquals(); 104 } 105 106 109 public int hashCode() { 110 return new HashCodeBuilder(-1168981869, -109522229).append(this.brand) 111 .append(this.type).append(this.model) 112 .append(this.carId).toHashCode(); 113 } 114 115 118 public String toString() { 119 return new ToStringBuilder(this).append("model", this.model).append( 120 "carId", this.carId).append( 121 "type", this.type).append( 122 "brand", this.brand).toString(); 123 } 124 125 126 127 } 128 | Popular Tags |