KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > PriceTier


1 /*
2  * Created on Aug 25, 2004
3  */

4 package com.openedit.store;
5
6 import org.openedit.money.Money;
7
8
9 /**
10  * @author Matthew Avery, mavery@einnovation.com
11  */

12 public class PriceTier
13 {
14     protected int fieldThresholdQuantity;
15     protected Price fieldPrice;
16     
17     public int getThresholdQuantity()
18     {
19         return fieldThresholdQuantity;
20     }
21     public void setThresholdQuantity( int thresholdQuantity )
22     {
23         fieldThresholdQuantity = thresholdQuantity;
24     }
25     public Price getPrice()
26     {
27         return fieldPrice;
28     }
29     public void setPrice( Price price )
30     {
31         fieldPrice = price;
32     }
33     
34     public Money getValue()
35     {
36         return getPrice().getValue();
37     }
38
39     public boolean equals(Object JavaDoc inObject)
40     {
41         if ( inObject instanceof PriceTier )
42         {
43             PriceTier pt = (PriceTier)inObject;
44             if ( getThresholdQuantity() != pt.getThresholdQuantity() )
45             {
46                 return false;
47             }
48             if ( getPrice() != null )
49             {
50                 if ( !getPrice().equals( pt.getPrice() ) )
51                 {
52                     return false;
53                 }
54             }
55             else if ( pt.getPrice() != null )
56             {
57                 return false;
58             }
59             return true;
60         }
61         else
62         {
63             return false;
64         }
65     }
66
67     public int hashCode()
68     {
69         int code = getThresholdQuantity() << 16;
70         if ( getPrice() != null )
71         {
72             code ^= getPrice().hashCode();
73         }
74         return code;
75     }
76 }
77
Popular Tags