1.1 --- a/task2/solution02/src/org/apidesign/apifest08/currency/MoneyImpl.java Wed Oct 01 10:43:05 2008 +0200
1.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/MoneyImpl.java Tue Oct 07 00:19:37 2008 +0200
1.3 @@ -15,7 +15,7 @@
1.4 private final BigDecimal amount;
1.5
1.6 private final Currency currency;
1.7 -
1.8 +
1.9 public MoneyImpl(BigDecimal amount, Currency currency) {
1.10 if (amount==null) throw new NullPointerException("Amount is null");
1.11 if (currency==null) throw new NullPointerException("Currency is null"+currency);
1.12 @@ -23,6 +23,8 @@
1.13 this.currency = currency;
1.14 }
1.15
1.16 +
1.17 +
1.18 public MoneyImpl(long amount, Currency currency) {
1.19 this(BigDecimal.valueOf(amount), currency);
1.20 }
1.21 @@ -30,6 +32,37 @@
1.22 public MoneyImpl(double amount, Currency currency) {
1.23 this(BigDecimal.valueOf(amount), currency);
1.24 }
1.25 +
1.26 + /**
1.27 + * Factory method.
1.28 + * @param amount
1.29 + * @param currency
1.30 + * @return
1.31 + */
1.32 + public static final Money money(BigDecimal amount, Currency currency)
1.33 + {
1.34 + return new MoneyImpl(amount, currency);
1.35 + }
1.36 + /**
1.37 + * Factory method.
1.38 + * @param amount
1.39 + * @param currency
1.40 + * @return
1.41 + */
1.42 + public static final Money money(long amount, Currency currency)
1.43 + {
1.44 + return new MoneyImpl(amount, currency);
1.45 + }
1.46 + /**
1.47 + * Factory method.
1.48 + * @param amount
1.49 + * @param currency
1.50 + * @return
1.51 + */
1.52 + public static final Money money(double amount, Currency currency)
1.53 + {
1.54 + return new MoneyImpl(amount, currency);
1.55 + }
1.56
1.57 /**
1.58 * Returns amount.