01: /*
02: *
03: * JMoney - A Personal Finance Manager
04: * Copyright (c) 2006 Nigel Westbury <westbury@users.sourceforge.net>
05: *
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20: *
21: */
22:
23: package net.sf.jmoney.model2;
24:
25: /**
26: * This is a helper class that makes it a little easier for
27: * a plug-in to extend the CurrencyAccount object.
28: *
29: * To add fields and methods to a CurrencyAccount object, one should
30: * derive a class from CurrencyAccountExtension. This mechanism
31: * allows multiple extensions to a CurrencyAccount object to be added
32: * and maintained at runtime.
33: *
34: * @author Nigel Westbury
35: */
36: public abstract class CurrencyAccountExtension extends AccountExtension {
37:
38: public CurrencyAccountExtension(ExtendableObject extendedObject) {
39: super (extendedObject);
40: }
41:
42: /*
43: * All extensions to CurrencyAccount objects implement the same methods that
44: * are in the CurrencyAccount object. This is for convenience so the
45: * comsumer can get a single object that supports both the original
46: * CurrencyAccount methods and the extension methods. All CurrencyAccount
47: * methods are passed on to the CurrencyAccount object.
48: */
49:
50: public Currency getCurrency() {
51: return getBaseObject().getCurrency();
52: }
53:
54: public Commodity getCommodity(Entry entry) {
55: return getBaseObject().getCommodity(entry);
56: }
57:
58: /**
59: * @return the initial balance of this account.
60: */
61: public long getStartBalance() {
62: return getBaseObject().getStartBalance();
63: }
64:
65: public void setCurrency(Currency currency) {
66: getBaseObject().setCurrency(currency);
67: }
68:
69: /**
70: * Sets the initial balance of this account.
71: * @param s the start balance
72: */
73: public void setStartBalance(long startBalance) {
74: getBaseObject().setStartBalance(startBalance);
75: }
76:
77: // This does some casting - perhaps this is not needed
78: // if generics are used????
79: @Override
80: public CurrencyAccount getBaseObject() {
81: return (CurrencyAccount) baseObject;
82: }
83: }
|