KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > rentacar > persistance > bo > Car


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 /**
13  *
14  * @author ofabre
15  *
16  */

17 @Entity
18 public class Car {
19     
20     // Fields
21
private String JavaDoc carId;
22     
23     private String JavaDoc type;
24     
25     private String JavaDoc brand;
26     
27     private String JavaDoc model;
28
29     public Car() {
30         super();
31         // TODO Auto-generated constructor stub
32
}
33     
34     public Car(String JavaDoc type, String JavaDoc brand, String JavaDoc model) {
35         super();
36         this.type = type;
37         this.brand = brand;
38         this.model = model;
39     }
40
41     public Car(String JavaDoc carId, String JavaDoc type, String JavaDoc brand, String JavaDoc model) {
42         super();
43         // TODO Auto-generated constructor stub
44
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         // TODO Auto-generated constructor stub
53
this.carId = carVO.getCarId();
54         this.type = carVO.getType();
55         this.brand = carVO.getBrand();
56         this.model = carVO.getModel();
57     }
58
59     public String JavaDoc getBrand() {
60         return brand;
61     }
62
63     public void setBrand(String JavaDoc brand) {
64         this.brand = brand;
65     }
66
67     @Id @GeneratedValue(generator = "system-uuid")
68     @GenericGenerator(name="system-uuid", strategy = "uuid")
69     public String JavaDoc getCarId() {
70         return carId;
71     }
72
73     public void setCarId(String JavaDoc carId) {
74         this.carId = carId;
75     }
76
77     public String JavaDoc getModel() {
78         return model;
79     }
80
81     public void setModel(String JavaDoc model) {
82         this.model = model;
83     }
84
85     public String JavaDoc getType() {
86         return type;
87     }
88
89     public void setType(String JavaDoc type) {
90         this.type = type;
91     }
92
93     /**
94      * @see java.lang.Object#equals(Object)
95      */

96     public boolean equals(Object JavaDoc 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     /**
107      * @see java.lang.Object#hashCode()
108      */

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     /**
116      * @see java.lang.Object#toString()
117      */

118     public String JavaDoc 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