1 /*
2 * MoneyWise: Finance Application
3 * Copyright 2012-2026. Tony Washer
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17 package io.github.tonywasher.joceanus.moneywise.atlas.data.analysis.values;
18
19 import io.github.tonywasher.joceanus.metis.data.MetisDataType;
20 import io.github.tonywasher.joceanus.moneywise.atlas.data.analysis.base.MoneyWiseXAnalysisAttribute;
21 import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleId;
22
23 /**
24 * TaxBasisAttribute enumeration.
25 */
26 public enum MoneyWiseXAnalysisTaxBasisAttr
27 implements MoneyWiseXAnalysisAttribute {
28 /**
29 * Gross Amount.
30 */
31 GROSS,
32
33 /**
34 * Nett Amount.
35 */
36 NETT,
37
38 /**
39 * TaxCredit.
40 */
41 TAXCREDIT;
42
43 /**
44 * The String name.
45 */
46 private String theName;
47
48 @Override
49 public String toString() {
50 /* If we have not yet loaded the name */
51 if (theName == null) {
52 /* Load the name */
53 theName = bundleIdForAttribute(this).getValue();
54 }
55
56 /* return the name */
57 return theName;
58 }
59
60 @Override
61 public boolean isPreserved() {
62 return true;
63 }
64
65 @Override
66 public MetisDataType getDataType() {
67 return MetisDataType.MONEY;
68 }
69
70 /**
71 * Obtain the resource bundleId for the attribute.
72 *
73 * @param pAttr the attribute
74 * @return the resource bundleId
75 */
76 private static OceanusBundleId bundleIdForAttribute(final MoneyWiseXAnalysisTaxBasisAttr pAttr) {
77 return switch (pAttr) {
78 case GROSS -> MoneyWiseXAnalysisValuesResource.TAXATTR_GROSS;
79 case NETT -> MoneyWiseXAnalysisValuesResource.TAXATTR_NETT;
80 case TAXCREDIT -> MoneyWiseXAnalysisValuesResource.TAXATTR_TAX;
81 default -> throw new IllegalArgumentException();
82 };
83 }
84 }