1 package org.apidesign.apifest08.currency;
4 * Amount is a class reprezenting an amount of many. It consist of
5 * whole currency amount and of pence amount. Both items are long values
6 * and it's not defined that the 100 pences = 1 amount. It's up to the converter
7 * to verify such invariants.
11 public final class Amount {
17 * Construct Amount with no pences.
19 * @param amount the amount in some currency
22 public Amount(long amount) {
28 * Construct Amount with the pences.
30 * @param amount the amount in some currency
31 * @param pence the pence count
33 public Amount(long amount, long pence) {
41 public long getAmount() {
46 * @param amount the amount to set
48 public void setAmount(long amount) {
55 public long getPence() {
60 * @param pence the pence to set
62 public void setPence(long pence) {
67 public boolean equals(Object obj) {
71 if (!(obj instanceof Amount)) {
74 Amount other = (Amount) obj;
75 return (amount == other.amount) && (pence == other.pence);
79 public int hashCode() {
81 hash = 79 * hash + (int) (this.amount ^ (this.amount >>> 32));
82 hash = 79 * hash + (int) (this.pence ^ (this.pence >>> 32));
87 public String toString() {
88 return amount + "." + pence;