KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > exception > User


1 // $Id: User.java,v 1.1 2004/11/11 20:56:43 steveebersole Exp $
2
package org.hibernate.test.exception;
3
4 import java.util.Set JavaDoc;
5 import java.util.HashSet JavaDoc;
6
7 /**
8  * Implementation of User.
9  *
10  * @author Steve Ebersole
11  */

12 public class User {
13     private Long JavaDoc id;
14     private String JavaDoc username;
15     private Set JavaDoc memberships = new HashSet JavaDoc();
16
17     public Long JavaDoc getId() {
18         return id;
19     }
20
21     public void setId(Long JavaDoc id) {
22         this.id = id;
23     }
24
25     public String JavaDoc getUsername() {
26         return username;
27     }
28
29     public void setUsername(String JavaDoc username) {
30         this.username = username;
31     }
32
33     public Set JavaDoc getMemberships() {
34         return memberships;
35     }
36
37     public void setMemberships(Set JavaDoc memberships) {
38         this.memberships = memberships;
39     }
40
41     public void addMembership(Group membership) {
42         if (membership == null) {
43             throw new IllegalArgumentException JavaDoc("Membership to add cannot be null");
44         }
45
46         this.memberships.add(membership);
47         membership.getMembers().add(this);
48     }
49 }
50
Popular Tags