1 package generated.model.de.fhdw.partner;
2
3 import de.fhdw.wtf.context.model.AnyType;
4 import de.fhdw.wtf.context.model.collections.MutableMap;
5 import de.fhdw.wtf.persistence.meta.UserObject;
6
7
8
9
10 public class IBAN_Finder extends AnyType {
11
12
13
14
15 private MutableMap<Country, MutableMap<Bankidentifier, MutableMap<AccountNumber, Account>>> accountTree;
16
17
18
19
20 public IBAN_Finder() {
21 this.accountTree = new MutableMap<>();
22 }
23
24
25
26
27
28
29
30 public IBAN_Finder(final UserObject userObject) {
31 super(userObject);
32 }
33
34
35
36
37
38
39
40
41
42
43
44
45 public Account findAccount(final Country country, final Bankidentifier blz, final AccountNumber number) {
46 final MutableMap<Bankidentifier, MutableMap<AccountNumber, Account>> countryMap = this.accountTree.get(country);
47 if (countryMap != null) {
48 final MutableMap<AccountNumber, Account> bankMap = countryMap.get(blz);
49 if (bankMap != null) {
50 final Account acc = bankMap.get(number);
51 return acc;
52 }
53 }
54 return null;
55 }
56
57
58
59
60
61
62
63
64
65
66
67
68
69 public void addAccount(final Country country,
70 final Bankidentifier blz,
71 final AccountNumber number,
72 final Account account) {
73 MutableMap<Bankidentifier, MutableMap<AccountNumber, Account>> countryMap = this.accountTree.get(country);
74 if (countryMap != null) {
75 MutableMap<AccountNumber, Account> bankMap = countryMap.get(blz);
76 if (bankMap != null) {
77 bankMap.put(number, account);
78 } else {
79 bankMap = new MutableMap<>();
80 bankMap.put(number, account);
81 countryMap.put(blz, bankMap);
82 }
83 } else {
84 countryMap = new MutableMap<>();
85 final MutableMap<AccountNumber, Account> bankMap = new MutableMap<>();
86 bankMap.put(number, account);
87 countryMap.put(blz, bankMap);
88 this.accountTree.put(country, countryMap);
89 }
90 }
91 }