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