author | japod@localhost |
Tue, 30 Sep 2008 11:47:02 +0200 | |
changeset 16 | 2864c6d744c0 |
parent 6 | 97662396c0fd |
permissions | -rw-r--r-- |
japod@6 | 1 |
package org.apidesign.apifest08.currency; |
japod@6 | 2 |
|
japod@6 | 3 |
|
japod@6 | 4 |
|
japod@6 | 5 |
/** |
japod@16 | 6 |
* Creates {@link Convertor} implementations. |
japod@6 | 7 |
* @author lukas |
japod@6 | 8 |
* |
japod@6 | 9 |
*/ |
japod@6 | 10 |
public class ConvertorFactory { |
japod@6 | 11 |
private ConvertorFactory() |
japod@6 | 12 |
{ |
japod@6 | 13 |
//nothing |
japod@6 | 14 |
} |
japod@6 | 15 |
|
japod@6 | 16 |
/** |
japod@6 | 17 |
* Creates {@link Convertor} that converts from sourceEquivalent.currency to destinationEquivalent.currency. |
japod@6 | 18 |
* Exchange rate is set as equivalents. It means if you want to create USD to CZK convertor where USD1 = CZK17 |
japod@16 | 19 |
* call createConvertor(new MoneyImpl(1, USD), new MoneyImpl(17, CZK)). Convertor created by this method |
japod@16 | 20 |
* rounds the result to two decimal places. |
japod@6 | 21 |
* @param sourceEquivalent |
japod@6 | 22 |
* @param destinationEquivalent |
japod@6 | 23 |
* @return |
japod@6 | 24 |
*/ |
japod@6 | 25 |
public static final Convertor createConvertor(Money sourceEquivalent, Money destinationEquivalent) |
japod@6 | 26 |
{ |
japod@6 | 27 |
return new DefaultConvertor(sourceEquivalent.getAmount(), destinationEquivalent.getAmount(), sourceEquivalent.getCurrency(), destinationEquivalent.getCurrency()); |
japod@6 | 28 |
} |
japod@6 | 29 |
|
japod@6 | 30 |
|
japod@6 | 31 |
} |