KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > filter > Product


1 // $Id: Product.java,v 1.3 2005/04/25 16:57:32 steveebersole Exp $
2
package org.hibernate.test.filter;
3
4 import java.util.Set JavaDoc;
5 import java.util.Date JavaDoc;
6 import java.util.HashSet JavaDoc;
7
8 /**
9  * @author Steve Ebersole
10  */

11 public class Product {
12     private Long JavaDoc id;
13     private String JavaDoc name;
14     private int stockNumber; // int for ease of hashCode() impl
15
private Date JavaDoc effectiveStartDate;
16     private Date JavaDoc effectiveEndDate;
17     private Set JavaDoc orderLineItems;
18     private Set JavaDoc categories;
19
20     public Long JavaDoc getId() {
21         return id;
22     }
23
24     public void setId(Long JavaDoc id) {
25         this.id = id;
26     }
27
28     public String JavaDoc getName() {
29         return name;
30     }
31
32     public void setName(String JavaDoc name) {
33         this.name = name;
34     }
35
36     public Set JavaDoc getOrderLineItems() {
37         return orderLineItems;
38     }
39
40     public void setOrderLineItems(Set JavaDoc orderLineItems) {
41         this.orderLineItems = orderLineItems;
42     }
43
44     public int getStockNumber() {
45         return stockNumber;
46     }
47
48     public void setStockNumber(int stockNumber) {
49         this.stockNumber = stockNumber;
50     }
51
52     public int hashCode() {
53         return stockNumber;
54     }
55
56     public boolean equals(Object JavaDoc obj) {
57         return ( (Product) obj ).stockNumber == this.stockNumber;
58     }
59
60     public Date JavaDoc getEffectiveStartDate() {
61         return effectiveStartDate;
62     }
63
64     public void setEffectiveStartDate(Date JavaDoc effectiveStartDate) {
65         this.effectiveStartDate = effectiveStartDate;
66     }
67
68     public Date JavaDoc getEffectiveEndDate() {
69         return effectiveEndDate;
70     }
71
72     public void setEffectiveEndDate(Date JavaDoc effectiveEndDate) {
73         this.effectiveEndDate = effectiveEndDate;
74     }
75
76     public Set JavaDoc getCategories() {
77         return categories;
78     }
79
80     public void setCategories(Set JavaDoc categories) {
81         this.categories = categories;
82     }
83
84     public void addCategory(Category category) {
85         if ( category == null ) {
86             return;
87         }
88
89         if ( categories == null ) {
90             categories = new HashSet JavaDoc();
91         }
92
93         categories.add( category );
94         if ( category.getProducts() == null ) {
95             category.setProducts( new HashSet JavaDoc() );
96         }
97         category.getProducts().add( this );
98     }
99 }
100
Popular Tags