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.ui;
18
19 import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleId;
20
21 /**
22 * Analysis Column Sets.
23 */
24 public enum MoneyWiseUIAnalysisColumnSet {
25 /**
26 * Balance.
27 */
28 BALANCE,
29
30 /**
31 * Standard.
32 */
33 STANDARD,
34
35 /**
36 * Salary.
37 */
38 SALARY,
39
40 /**
41 * Interest.
42 */
43 INTEREST,
44
45 /**
46 * Dividend.
47 */
48 DIVIDEND,
49
50 /**
51 * Security.
52 */
53 SECURITY,
54
55 /**
56 * All.
57 */
58 ALL;
59
60 /**
61 * Report Name.
62 */
63 private String theName;
64
65 @Override
66 public String toString() {
67 /* If we have not yet loaded the name */
68 if (theName == null) {
69 /* Load the name */
70 theName = bundleIdForColumnSet(this).getValue();
71 }
72
73 /* return the name */
74 return theName;
75 }
76
77 /**
78 * Is this the balance set?
79 *
80 * @return true/false
81 */
82 public boolean isBalance() {
83 return BALANCE.equals(this);
84 }
85
86 /**
87 * Obtain the resource bundleId for the set.
88 *
89 * @param pSet the set
90 * @return the resource bundleId
91 */
92 private static OceanusBundleId bundleIdForColumnSet(final MoneyWiseUIAnalysisColumnSet pSet) {
93 return switch (pSet) {
94 case BALANCE -> MoneyWiseUIResource.COLUMNSET_BALANCE;
95 case STANDARD -> MoneyWiseUIResource.COLUMNSET_STANDARD;
96 case SALARY -> MoneyWiseUIResource.COLUMNSET_SALARY;
97 case INTEREST -> MoneyWiseUIResource.COLUMNSET_INTEREST;
98 case DIVIDEND -> MoneyWiseUIResource.COLUMNSET_DIVIDEND;
99 case SECURITY -> MoneyWiseUIResource.COLUMNSET_SECURITY;
100 case ALL -> MoneyWiseUIResource.COLUMNSET_ALL;
101 default -> throw new IllegalArgumentException();
102 };
103 }
104 }