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 return switch (this) {
177 case UNITS, DIVIDEND, RESIDUALCOST, VALUATION, EXCHANGERATE, VALUE, PRICE, REALISEDGAINS, UNREALISEDGAINS,
178 GAINSADJUST, FUNDED, STARTDATE -> true;
179 default -> false;
180 };
181 }
182
183 @Override
184 public MetisDataType getDataType() {
185 return switch (this) {
186 case UNITS -> MetisDataType.UNITS;
187 case PRICE -> MetisDataType.PRICE;
188 case EXCHANGERATE, COSTDILUTION -> MetisDataType.RATIO;
189 case CASHTYPE -> MetisDataType.ENUM;
190 case STARTDATE -> MetisDataType.DATE;
191 default -> MetisDataType.MONEY;
192 };
193 }
194 }