1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.moneywise.data.validate;
18
19 import io.github.tonywasher.joceanus.metis.list.MetisListKey;
20 import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseBasicDataType;
21 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseStaticDataType;
22 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataSet.PrometheusCryptographyDataType;
23 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataValidator;
24 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataValidator.PrometheusDataValidatorFactory;
25 import io.github.tonywasher.joceanus.prometheus.validate.PrometheusValidateBasic;
26 import io.github.tonywasher.joceanus.prometheus.validate.PrometheusValidateInfo;
27 import io.github.tonywasher.joceanus.prometheus.validate.PrometheusValidateStatic;
28
29
30
31
32 public class MoneyWiseValidatorFactory
33 implements PrometheusDataValidatorFactory {
34
35
36
37 private final boolean newValidation;
38
39
40
41
42 public MoneyWiseValidatorFactory() {
43 this(false);
44 }
45
46
47
48
49
50
51 public MoneyWiseValidatorFactory(final boolean pNewValidation) {
52 newValidation = pNewValidation;
53 }
54
55 @Override
56 public PrometheusDataValidator newValidator(final MetisListKey pItemType) {
57 if (pItemType instanceof PrometheusCryptographyDataType) {
58 return new PrometheusValidateBasic();
59 } else if (MoneyWiseStaticDataType.CURRENCY.equals(pItemType)) {
60 return new MoneyWiseValidateCurrency();
61 } else if (pItemType instanceof MoneyWiseStaticDataType) {
62 return new PrometheusValidateStatic();
63 } else if (pItemType instanceof MoneyWiseBasicDataType myType) {
64 switch (myType) {
65 case TRANSTAG:
66 return new MoneyWiseValidateTransTag();
67 case REGION:
68 return new MoneyWiseValidateRegion();
69 case DEPOSITCATEGORY:
70 return new MoneyWiseValidateDepositCategory();
71 case CASHCATEGORY:
72 return new MoneyWiseValidateCashCategory();
73 case LOANCATEGORY:
74 return new MoneyWiseValidateLoanCategory();
75 case TRANSCATEGORY:
76 return new MoneyWiseValidateTransCategory();
77 case EXCHANGERATE:
78 return new MoneyWiseValidateXchangeRate();
79 case PAYEE:
80 return new MoneyWiseValidatePayee();
81 case SECURITY:
82 return new MoneyWiseValidateSecurity();
83 case SECURITYPRICE:
84 return new MoneyWiseValidateSecurityPrice();
85 case DEPOSIT:
86 return new MoneyWiseValidateDeposit();
87 case DEPOSITRATE:
88 return new MoneyWiseValidateDepositRate();
89 case CASH:
90 return new MoneyWiseValidateCash();
91 case LOAN:
92 return new MoneyWiseValidateLoan();
93 case PORTFOLIO:
94 return new MoneyWiseValidatePortfolio();
95 case TRANSACTION:
96 return new MoneyWiseValidateTransaction(newValidation);
97 case PAYEEINFO:
98 case DEPOSITINFO:
99 case SECURITYINFO:
100 case CASHINFO:
101 case LOANINFO:
102 case PORTFOLIOINFO:
103 case TRANSACTIONINFO:
104 return new PrometheusValidateInfo();
105 default:
106 break;
107 }
108 }
109
110
111 throw new IllegalArgumentException("Unexpected itemType " + pItemType);
112 }
113 }