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.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  
22  /**
23   * AccountAttribute enumeration.
24   */
25  public enum MoneyWiseXAnalysisAccountAttr
26          implements MoneyWiseXAnalysisAttribute {
27      /**
28       * Local Currency Balance.
29       */
30      BALANCE,
31  
32      /**
33       * Exchange Rate.
34       */
35      EXCHANGERATE,
36  
37      /**
38       * Reported Valuation.
39       */
40      VALUATION,
41  
42      /**
43       * Valuation Delta.
44       */
45      VALUEDELTA,
46  
47      /**
48       * Deposit Rate.
49       */
50      DEPOSITRATE,
51  
52      /**
53       * Maturity.
54       */
55      MATURITY;
56  
57      /**
58       * The String name.
59       */
60      private String theName;
61  
62      @Override
63      public String toString() {
64          /* If we have not yet loaded the name */
65          if (theName == null) {
66              /* Load the name */
67              theName = MoneyWiseXAnalysisValuesResource.getKeyForAccountAttr(this).getValue();
68          }
69  
70          /* return the name */
71          return theName;
72      }
73  
74      @Override
75      public boolean isPreserved() {
76          return switch (this) {
77              case BALANCE, MATURITY, DEPOSITRATE, EXCHANGERATE, VALUATION -> true;
78              default -> false;
79          };
80      }
81  
82      @Override
83      public MetisDataType getDataType() {
84          return switch (this) {
85              case DEPOSITRATE -> MetisDataType.RATE;
86              case EXCHANGERATE -> MetisDataType.RATIO;
87              case MATURITY -> MetisDataType.DATE;
88              default -> MetisDataType.MONEY;
89          };
90      }
91  }