/*
* Copyright (c) 2004-2011 Marco Maccaferri and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marco Maccaferri - initial API and implementation
*/
package org.eclipsetrader.core;
import java.util.Currency;
public class Cash {
private Double amount;
private Currency currency;
public Cash(Double amount, Currency currency) {
this.amount = amount;
this.currency = currency;
}
public Double getAmount() {
return amount;
}
public Currency getCurrency() {
return currency;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return 7 * currency.hashCode() + 11 * amount.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Cash)) {
return false;
}
Cash that = (Cash) obj;
return getAmount().equals(that.getAmount()) && getCurrency().equals(that.getCurrency());
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return currency.getSymbol() + " " + String.valueOf(amount);
}
}