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   * SecurityAttribute enumeration.
24   */
25  public enum MoneyWiseXAnalysisSecurityAttr
26          implements MoneyWiseXAnalysisAttribute {
27      /**
28       * Units.
29       */
30      UNITS,
31  
32      /**
33       * Price in local currency.
34       */
35      PRICE,
36  
37      /**
38       * Value in local currency.
39       */
40      VALUE,
41  
42      /**
43       * Exchange Rate.
44       */
45      EXCHANGERATE,
46  
47      /**
48       * Reporting Valuation.
49       */
50      VALUATION,
51  
52      /**
53       * Valuation Delta.
54       */
55      VALUEDELTA,
56  
57      /**
58       * Residual Cost.
59       */
60      RESIDUALCOST,
61  
62      /**
63       * RealisedGains.
64       */
65      REALISEDGAINS,
66  
67      /**
68       * UnrealisedGains.
69       */
70      UNREALISEDGAINS,
71  
72      /**
73       * UnrealisedGainsAdjust.
74       */
75      GAINSADJUST,
76  
77      /**
78       * Dividend.
79       */
80      DIVIDEND,
81  
82      /**
83       * Profit.
84       */
85      PROFIT,
86  
87      /**
88       * Profit.
89       */
90      MARKETPROFIT,
91  
92      /**
93       * CashInvested.
94       */
95      CASHINVESTED,
96  
97      /**
98       * CashConsideration (returned cash).
99       */
100     RETURNEDCASH,
101 
102     /**
103      * StockConsideration (transferred value).
104      */
105     XFERREDVALUE,
106 
107     /**
108      * Capital Gain.
109      */
110     CAPITALGAIN,
111 
112     /**
113      * AllowedCost.
114      */
115     ALLOWEDCOST,
116 
117     /**
118      * XferredCost.
119      */
120     XFERREDCOST,
121 
122     /**
123      * Funded.
124      */
125     FUNDED,
126 
127     /**
128      * StartDate.
129      */
130     STARTDATE,
131 
132     /**
133      * SliceYears.
134      */
135     SLICEYEARS,
136 
137     /**
138      * SliceGain.
139      */
140     SLICEGAIN,
141 
142     /**
143      * Consideration.
144      */
145     CONSIDERATION,
146 
147     /**
148      * CostDilution.
149      */
150     COSTDILUTION,
151 
152     /**
153      * CashType.
154      */
155     CASHTYPE;
156 
157     /**
158      * The String name.
159      */
160     private String theName;
161 
162     @Override
163     public String toString() {
164         /* If we have not yet loaded the name */
165         if (theName == null) {
166             /* Load the name */
167             theName = MoneyWiseXAnalysisValuesResource.getKeyForSecurityAttr(this).getValue();
168         }
169 
170         /* return the name */
171         return theName;
172     }
173 
174     @Override
175     public boolean isPreserved() {
176         switch (this) {
177             case UNITS:
178             case DIVIDEND:
179             case RESIDUALCOST:
180             case VALUATION:
181             case EXCHANGERATE:
182             case VALUE:
183             case PRICE:
184             case REALISEDGAINS:
185             case UNREALISEDGAINS:
186             case GAINSADJUST:
187             case FUNDED:
188             case STARTDATE:
189                 return true;
190             case PROFIT:
191             case MARKETPROFIT:
192             case VALUEDELTA:
193             case XFERREDCOST:
194             case RETURNEDCASH:
195             case XFERREDVALUE:
196             case CASHINVESTED:
197             case CAPITALGAIN:
198             case ALLOWEDCOST:
199             case CONSIDERATION:
200             case COSTDILUTION:
201             case CASHTYPE:
202             default:
203                 return false;
204         }
205     }
206 
207     @Override
208     public MetisDataType getDataType() {
209         switch (this) {
210             case UNITS:
211                 return MetisDataType.UNITS;
212             case PRICE:
213                 return MetisDataType.PRICE;
214             case EXCHANGERATE:
215             case COSTDILUTION:
216                 return MetisDataType.RATIO;
217             case CASHTYPE:
218                 return MetisDataType.ENUM;
219             case STARTDATE:
220                 return MetisDataType.DATE;
221             case VALUE:
222             case VALUATION:
223             case VALUEDELTA:
224             case RESIDUALCOST:
225             case REALISEDGAINS:
226             case UNREALISEDGAINS:
227             case GAINSADJUST:
228             case DIVIDEND:
229             case MARKETPROFIT:
230             case PROFIT:
231             case RETURNEDCASH:
232             case XFERREDVALUE:
233             case XFERREDCOST:
234             case ALLOWEDCOST:
235             case CASHINVESTED:
236             case CAPITALGAIN:
237             case CONSIDERATION:
238             case FUNDED:
239             default:
240                 return MetisDataType.MONEY;
241         }
242     }
243 }