KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > domain > Customer


1 /*
2  * Created on Feb 22, 2003
3  */

4 package xpetstore.domain;
5
6 import java.io.Serializable JavaDoc;
7
8
9 /**
10  * @author <a HREF="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
11  *
12  * @hibernate.class
13  * table="T_CUSTOMER"
14  */

15 public class Customer
16     implements Serializable JavaDoc
17 {
18     //~ Instance fields --------------------------------------------------------
19

20     private Account _account = new Account( );
21     private Address _address = new Address( );
22     private CreditCard _creditCard = new CreditCard( );
23     private String JavaDoc _email = "";
24     private String JavaDoc _firstname = "";
25     private String JavaDoc _language = "";
26     private String JavaDoc _lastname = "";
27     private String JavaDoc _telephone = "";
28
29     //~ Constructors -----------------------------------------------------------
30

31     public Customer( ) {}
32
33     public Customer( Account account )
34     {
35         _account = account;
36     }
37
38     //~ Methods ----------------------------------------------------------------
39

40     /**
41      * @return Account
42      *
43      * @hibernate.one-to-one
44      * cascade="all"
45      */

46     public Account getAccount( )
47     {
48         return _account;
49     }
50
51     /**
52      * @return Address
53      *
54      * @hibernate.component
55      */

56     public Address getAddress( )
57     {
58         return _address;
59     }
60
61     /**
62      * @return CreditCard
63      *
64      * @hibernate.component
65      */

66     public CreditCard getCreditCard( )
67     {
68         return _creditCard;
69     }
70
71     /**
72      * @return String
73      *
74      * @hibernate.id
75      * generator-class="assigned"
76      * length="10"
77      */

78     public String JavaDoc getUserId( )
79     {
80         return ( _account != null )
81                ? _account.getUserId( )
82                : "";
83     }
84
85     /**
86      * @return String
87      *
88      * @hibernate.property
89      * length="255"
90      * not-null="true"
91      * unique="true"
92      */

93     public String JavaDoc getEmail( )
94     {
95         return _email;
96     }
97
98     /**
99      * @return String
100      *
101      * @hibernate.property
102      * length="50"
103      */

104     public String JavaDoc getFirstname( )
105     {
106         return _firstname;
107     }
108
109     /**
110      * @return String
111      *
112      * @hibernate.property
113      * length="3"
114      */

115     public String JavaDoc getLanguage( )
116     {
117         return _language;
118     }
119
120     /**
121      * @return String
122      *
123      * @hibernate.property
124      * length="50"
125      */

126     public String JavaDoc getLastname( )
127     {
128         return _lastname;
129     }
130
131     /**
132      * @return String
133      *
134      * @hibernate.property
135      * length="10"
136      */

137     public String JavaDoc getTelephone( )
138     {
139         return _telephone;
140     }
141
142     public void set( Customer cst )
143     {
144         _account.set( cst.getAccount( ) );
145         _address.set( cst.getAddress( ) );
146         _creditCard.set( cst.getCreditCard( ) );
147         _email = cst.getEmail( );
148         _firstname = cst.getFirstname( );
149         _lastname = cst.getLastname( );
150         _language = cst.getLanguage( );
151         _telephone = cst.getTelephone( );
152     }
153
154     /**
155      * Sets the account.
156      * @param account The account to set
157      */

158     public void setAccount( Account account )
159     {
160         _account = account;
161     }
162
163     /**
164      * Sets the address.
165      * @param address The address to set
166      */

167     public void setAddress( Address address )
168     {
169         _address = address;
170     }
171
172     /**
173      * Sets the creditCard.
174      * @param creditCard The creditCard to set
175      */

176     public void setCreditCard( CreditCard creditCard )
177     {
178         _creditCard = creditCard;
179     }
180
181     /**
182      * Sets the userId.
183      * @param userId The userId to set
184      */

185     public void setUserId( String JavaDoc userId )
186     {
187         if ( _account == null )
188         {
189             _account = new Account( );
190         }
191
192         _account.setUserId( userId );
193     }
194
195     /**
196      * Sets the email.
197      * @param email The email to set
198      */

199     public void setEmail( String JavaDoc email )
200     {
201         _email = email;
202     }
203
204     /**
205      * Sets the firstname.
206      * @param firstname The firstname to set
207      */

208     public void setFirstname( String JavaDoc firstname )
209     {
210         _firstname = firstname;
211     }
212
213     /**
214      * Sets the language.
215      * @param language The language to set
216      */

217     public void setLanguage( String JavaDoc language )
218     {
219         _language = language;
220     }
221
222     /**
223      * Sets the lastname.
224      * @param lastname The lastname to set
225      */

226     public void setLastname( String JavaDoc lastname )
227     {
228         _lastname = lastname;
229     }
230
231     /**
232      * Sets the telephone.
233      * @param telephone The telephone to set
234      */

235     public void setTelephone( String JavaDoc telephone )
236     {
237         _telephone = telephone;
238     }
239 }
240
Popular Tags