View Javadoc
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.lethe.reports;
18  
19  import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleId;
20  import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleLoader;
21  import io.github.tonywasher.joceanus.moneywise.lethe.data.analysis.data.MoneyWiseAnalysisDataResource;
22  
23  import java.util.EnumMap;
24  import java.util.Map;
25  import java.util.ResourceBundle;
26  
27  /**
28   * Resource IDs for MoneyWise Report Fields.
29   */
30  public enum MoneyWiseReportResource implements OceanusBundleId {
31      /**
32       * NetWorth ReportType.
33       */
34      TYPE_NETWORTH("Type.NetWorth"),
35  
36      /**
37       * BalanceSheet ReportType.
38       */
39      TYPE_BALANCESHEET("Type.BalanceSheet"),
40  
41      /**
42       * CashFlow ReportType.
43       */
44      TYPE_CASHFLOW("Type.CashFlow"),
45  
46      /**
47       * IncomeExpense ReportType.
48       */
49      TYPE_INCEXP("Type.IncExp"),
50  
51      /**
52       * Portfolio ReportType.
53       */
54      TYPE_PORTFOLIO("Type.Portfolio"),
55  
56      /**
57       * MarketGrowth ReportType.
58       */
59      TYPE_MARKET("Type.Market"),
60  
61      /**
62       * TaxBasis ReportType.
63       */
64      TYPE_TAXBASIS("Type.TaxBasis"),
65  
66      /**
67       * TaxCalc ReportType.
68       */
69      TYPE_TAXCALC("Type.TaxCalc"),
70  
71      /**
72       * AssetGains ReportType.
73       */
74      TYPE_ASSETGAINS("Type.AssetGains"),
75  
76      /**
77       * CapitalGains ReportType.
78       */
79      TYPE_CAPITALGAINS("Type.CapitalGains"),
80  
81      /**
82       * NetWorth Title.
83       */
84      NETWORTH_TITLE("NetWorth.Title"),
85  
86      /**
87       * NetWorth Asset.
88       */
89      NETWORTH_ASSET("NetWorth.Asset"),
90  
91      /**
92       * BalanceSheet Title.
93       */
94      BALANCESHEET_TITLE("BalanceSheet.Title"),
95  
96      /**
97       * CashFlow Title.
98       */
99      CASHFLOW_TITLE("CashFlow.Title"),
100 
101     /**
102      * Income/Expense Title.
103      */
104     INCEXP_TITLE("IncExp.Title"),
105 
106     /**
107      * Portfolio Title.
108      */
109     PORTFOLIO_TITLE("Portfolio.Title"),
110 
111     /**
112      * MarketGrowth Title.
113      */
114     MARKETGROWTH_TITLE("MarketGrowth.Title"),
115 
116     /**
117      * MarketGrowth BaseValue.
118      */
119     MARKETGROWTH_BASE("MarketGrowth.Base"),
120 
121     /**
122      * AssetGains Title.
123      */
124     ASSETGAINS_TITLE("AssetGains.Title"),
125 
126     /**
127      * CapitalGains Title.
128      */
129     CAPITALGAINS_TITLE("CapitalGains.Title"),
130 
131     /**
132      * TaxBasis Title.
133      */
134     TAXBASIS_TITLE("TaxBasis.Title"),
135 
136     /**
137      * TaxCalc Title.
138      */
139     TAXCALC_TITLE("TaxCalc.Title");
140 
141     /**
142      * The Report Map.
143      */
144     private static final Map<MoneyWiseReportType, OceanusBundleId> REPORT_MAP = buildReportMap();
145 
146     /**
147      * The Resource Loader.
148      */
149     private static final OceanusBundleLoader LOADER = OceanusBundleLoader.getLoader(MoneyWiseAnalysisDataResource.class.getCanonicalName(),
150             ResourceBundle::getBundle);
151 
152     /**
153      * The Id.
154      */
155     private final String theKeyName;
156 
157     /**
158      * The Value.
159      */
160     private String theValue;
161 
162     /**
163      * Constructor.
164      *
165      * @param pKeyName the key name
166      */
167     MoneyWiseReportResource(final String pKeyName) {
168         theKeyName = pKeyName;
169     }
170 
171     @Override
172     public String getKeyName() {
173         return theKeyName;
174     }
175 
176     @Override
177     public String getNameSpace() {
178         return "MoneyWise.report";
179     }
180 
181     @Override
182     public String getValue() {
183         /* If we have not initialised the value */
184         if (theValue == null) {
185             /* Derive the value */
186             theValue = LOADER.getValue(this);
187         }
188 
189         /* return the value */
190         return theValue;
191     }
192 
193     /**
194      * Build report map.
195      *
196      * @return the map
197      */
198     private static Map<MoneyWiseReportType, OceanusBundleId> buildReportMap() {
199         /* Create the map and return it */
200         final Map<MoneyWiseReportType, OceanusBundleId> myMap = new EnumMap<>(MoneyWiseReportType.class);
201         myMap.put(MoneyWiseReportType.NETWORTH, TYPE_NETWORTH);
202         myMap.put(MoneyWiseReportType.BALANCESHEET, TYPE_BALANCESHEET);
203         myMap.put(MoneyWiseReportType.CASHFLOW, TYPE_CASHFLOW);
204         myMap.put(MoneyWiseReportType.INCOMEEXPENSE, TYPE_INCEXP);
205         myMap.put(MoneyWiseReportType.PORTFOLIO, TYPE_PORTFOLIO);
206         myMap.put(MoneyWiseReportType.MARKETGROWTH, TYPE_MARKET);
207         myMap.put(MoneyWiseReportType.TAXBASIS, TYPE_TAXBASIS);
208         myMap.put(MoneyWiseReportType.TAXCALC, TYPE_TAXCALC);
209         myMap.put(MoneyWiseReportType.ASSETGAINS, TYPE_ASSETGAINS);
210         myMap.put(MoneyWiseReportType.CAPITALGAINS, TYPE_CAPITALGAINS);
211         return myMap;
212     }
213 
214     /**
215      * Obtain key for report type.
216      *
217      * @param pValue the Value
218      * @return the resource key
219      */
220     protected static OceanusBundleId getKeyForReportType(final MoneyWiseReportType pValue) {
221         return OceanusBundleLoader.getKeyForEnum(REPORT_MAP, pValue);
222     }
223 }