| 1 | package net.sourceforge.finmodel.account; |
| 2 | |
| 3 | import java.math.BigDecimal; |
| 4 | import java.util.ArrayList; |
| 5 | import java.util.List; |
| 6 | |
| 7 | import net.sourceforge.finmodel.asset.Cash; |
| 8 | import net.sourceforge.finmodel.rules.APRRule; |
| 9 | import net.sourceforge.finmodel.rules.Rule; |
| 10 | |
| 11 | public class InterestAccount extends AccountImpl { |
| 12 | private CashAccount interestSource; |
| 13 | private APRRule interestRule; |
| 14 | static final long serialVersionUID = 1L; |
| 15 | |
| 16 | public InterestAccount() { |
| 17 | |
| 18 | } |
| 19 | |
| 20 | public InterestAccount(BigDecimal rate) { |
| 21 | super( "INTEREST", Cash.getInstance()); |
| 22 | init("INTEREST", rate); |
| 23 | } |
| 24 | |
| 25 | public InterestAccount(String name, BigDecimal rate) { |
| 26 | super( name, Cash.getInstance()); |
| 27 | init(name, rate); |
| 28 | } |
| 29 | |
| 30 | private void init(String name, BigDecimal rate) { |
| 31 | interestSource = new CashAccount("INT: " + name); |
| 32 | interestRule = new APRRule(); |
| 33 | interestRule.setSource(interestSource); |
| 34 | interestRule.setDestination(this); |
| 35 | interestRule.setExamine(this); |
| 36 | interestRule.setAPR(rate); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | public List<Rule> getInherentRules() { |
| 41 | List<Rule> rc = new ArrayList<Rule>(); |
| 42 | rc.add(interestRule); |
| 43 | return rc; |
| 44 | } |
| 45 | } |