FileDocCategorySizeDatePackage
MonetaryAmount.javaAPI DocHibernate 3.2.52080Tue May 08 16:56:00 BST 2007org.hibernate.test.sql.hand

MonetaryAmount

public class MonetaryAmount extends Object implements Serializable
Represents a monetary amount as value and currency.
author
Gavin King
author
Christian Bauer

Fields Summary
private final BigDecimal
value
private final Currency
currency
Constructors Summary
public MonetaryAmount(BigDecimal value, Currency currency)

		this.value = value;
		this.currency = currency;
	
Methods Summary
public intcompareTo(java.lang.Object o)

		if (o instanceof MonetaryAmount) {
			// TODO: This would actually require some currency conversion magic
			return this.getValue().compareTo(((MonetaryAmount) o).getValue());
		}
		return 0;
	
public static org.hibernate.test.sql.hand.MonetaryAmountconvert(org.hibernate.test.sql.hand.MonetaryAmount amount, java.util.Currency toConcurrency)

		// TODO: This requires some conversion magic and is therefore broken
		return new MonetaryAmount(amount.getValue(), toConcurrency);
	
public booleanequals(java.lang.Object o)

		if (this == o) return true;
		if (!(o instanceof MonetaryAmount)) return false;

		final MonetaryAmount monetaryAmount = (MonetaryAmount) o;

		if (!currency.equals(monetaryAmount.currency)) return false;
		if (!value.equals(monetaryAmount.value)) return false;

		return true;
	
public static org.hibernate.test.sql.hand.MonetaryAmountfromString(java.lang.String amount, java.lang.String currencyCode)

		return new MonetaryAmount(new BigDecimal(amount),
								  Currency.getInstance(currencyCode));
	
public java.util.CurrencygetCurrency()

		return currency;
	
public java.math.BigDecimalgetValue()

		return value;
	
public inthashCode()

		int result;
		result = value.hashCode();
		result = 29 * result + currency.hashCode();
		return result;
	
public java.lang.StringtoString()

		return "Value: '" + getValue() + "', " +
		        "Currency: '" + getCurrency() + "'";