forked from google/gdata-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortfolioData.java
More file actions
634 lines (557 loc) · 16.6 KB
/
Copy pathPortfolioData.java
File metadata and controls
634 lines (557 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
/* Copyright (c) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gdata.data.finance;
import com.google.gdata.data.AttributeGenerator;
import com.google.gdata.data.AttributeHelper;
import com.google.gdata.data.ExtensionDescription;
import com.google.gdata.data.ExtensionPoint;
import com.google.gdata.data.ExtensionProfile;
import com.google.gdata.util.ParseException;
/**
* Data for the portfolio.
*
*
*/
@ExtensionDescription.Default(
nsAlias = FinanceNamespace.GF_ALIAS,
nsUri = FinanceNamespace.GF,
localName = PortfolioData.XML_NAME)
public class PortfolioData extends ExtensionPoint {
/** XML element name */
static final String XML_NAME = "portfolioData";
/** XML "currencyCode" attribute name */
private static final String CURRENCYCODE = "currencyCode";
/** XML "gainPercentage" attribute name */
private static final String GAINPERCENTAGE = "gainPercentage";
/** XML "return1w" attribute name */
private static final String RETURN1W = "return1w";
/** XML "return1y" attribute name */
private static final String RETURN1Y = "return1y";
/** XML "return3m" attribute name */
private static final String RETURN3M = "return3m";
/** XML "return3y" attribute name */
private static final String RETURN3Y = "return3y";
/** XML "return4w" attribute name */
private static final String RETURN4W = "return4w";
/** XML "return5y" attribute name */
private static final String RETURN5Y = "return5y";
/** XML "returnOverall" attribute name */
private static final String RETURNOVERALL = "returnOverall";
/** XML "returnYTD" attribute name */
private static final String RETURNYTD = "returnYTD";
/** ISO4217 currency code */
private String currencyCode = null;
/** Percentage gain */
private Double gainPercentage = null;
/** 1 week return (percentage) */
private Double return1w = null;
/** 1 year return (percentage) */
private Double return1y = null;
/** 3 month return (percentage) */
private Double return3m = null;
/** 3 year return (percentage) */
private Double return3y = null;
/** 4 week return (percentage) */
private Double return4w = null;
/** 5 year return (percentage) */
private Double return5y = null;
/** Overall return (percentage) */
private Double returnOverall = null;
/** Year-to-date return (percentage) */
private Double returnYTD = null;
/**
* Default mutable constructor.
*/
public PortfolioData() {
super();
}
/**
* Immutable constructor.
*
* @param currencyCode ISO4217 currency code.
* @param gainPercentage percentage gain.
* @param return1w 1 week return (percentage).
* @param return1y 1 year return (percentage).
* @param return3m 3 month return (percentage).
* @param return3y 3 year return (percentage).
* @param return4w 4 week return (percentage).
* @param return5y 5 year return (percentage).
* @param returnOverall overall return (percentage).
* @param returnYTD Year-to-date return (percentage).
*/
public PortfolioData(String currencyCode, Double gainPercentage,
Double return1w, Double return1y, Double return3m, Double return3y,
Double return4w, Double return5y, Double returnOverall,
Double returnYTD) {
super();
setCurrencyCode(currencyCode);
setGainPercentage(gainPercentage);
setReturn1w(return1w);
setReturn1y(return1y);
setReturn3m(return3m);
setReturn3y(return3y);
setReturn4w(return4w);
setReturn5y(return5y);
setReturnOverall(returnOverall);
setReturnYTD(returnYTD);
setImmutable(true);
}
@Override
public void declareExtensions(ExtensionProfile extProfile) {
if (extProfile.isDeclared(PortfolioData.class)) {
return;
}
extProfile.declare(PortfolioData.class, CostBasis.class);
new CostBasis().declareExtensions(extProfile);
extProfile.declare(PortfolioData.class, DaysGain.class);
new DaysGain().declareExtensions(extProfile);
extProfile.declare(PortfolioData.class, Gain.class);
new Gain().declareExtensions(extProfile);
extProfile.declare(PortfolioData.class, MarketValue.class);
new MarketValue().declareExtensions(extProfile);
}
/**
* Returns the cost basis of the portfolio in the portfolio default currency.
*
* @return cost basis of the portfolio in the portfolio default currency
*/
public CostBasis getCostBasis() {
return getExtension(CostBasis.class);
}
/**
* Sets the cost basis of the portfolio in the portfolio default currency.
*
* @param costBasis cost basis of the portfolio in the portfolio default
* currency or <code>null</code> to reset
*/
public void setCostBasis(CostBasis costBasis) {
if (costBasis == null) {
removeExtension(CostBasis.class);
} else {
setExtension(costBasis);
}
}
/**
* Returns whether it has the cost basis of the portfolio in the portfolio
* default currency.
*
* @return whether it has the cost basis of the portfolio in the portfolio
* default currency
*/
public boolean hasCostBasis() {
return hasExtension(CostBasis.class);
}
/**
* Returns the ISO4217 currency code.
*
* @return ISO4217 currency code
*/
public String getCurrencyCode() {
return currencyCode;
}
/**
* Sets the ISO4217 currency code.
*
* @param currencyCode ISO4217 currency code or <code>null</code> to reset
*/
public void setCurrencyCode(String currencyCode) {
throwExceptionIfImmutable();
this.currencyCode = currencyCode;
}
/**
* Returns whether it has the ISO4217 currency code.
*
* @return whether it has the ISO4217 currency code
*/
public boolean hasCurrencyCode() {
return getCurrencyCode() != null;
}
/**
* Returns the today's gain for the portfolio in the portfolio default
* currency.
*
* @return today's gain for the portfolio in the portfolio default currency
*/
public DaysGain getDaysGain() {
return getExtension(DaysGain.class);
}
/**
* Sets the today's gain for the portfolio in the portfolio default currency.
*
* @param daysGain today's gain for the portfolio in the portfolio default
* currency or <code>null</code> to reset
*/
public void setDaysGain(DaysGain daysGain) {
if (daysGain == null) {
removeExtension(DaysGain.class);
} else {
setExtension(daysGain);
}
}
/**
* Returns whether it has the today's gain for the portfolio in the portfolio
* default currency.
*
* @return whether it has the today's gain for the portfolio in the portfolio
* default currency
*/
public boolean hasDaysGain() {
return hasExtension(DaysGain.class);
}
/**
* Returns the gain for the portfolio in the portfolio default currency.
*
* @return gain for the portfolio in the portfolio default currency
*/
public Gain getGain() {
return getExtension(Gain.class);
}
/**
* Sets the gain for the portfolio in the portfolio default currency.
*
* @param gain gain for the portfolio in the portfolio default currency or
* <code>null</code> to reset
*/
public void setGain(Gain gain) {
if (gain == null) {
removeExtension(Gain.class);
} else {
setExtension(gain);
}
}
/**
* Returns whether it has the gain for the portfolio in the portfolio default
* currency.
*
* @return whether it has the gain for the portfolio in the portfolio default
* currency
*/
public boolean hasGain() {
return hasExtension(Gain.class);
}
/**
* Returns the percentage gain.
*
* @return percentage gain
*/
public Double getGainPercentage() {
return gainPercentage;
}
/**
* Sets the percentage gain.
*
* @param gainPercentage percentage gain or <code>null</code> to reset
*/
public void setGainPercentage(Double gainPercentage) {
throwExceptionIfImmutable();
this.gainPercentage = gainPercentage;
}
/**
* Returns whether it has the percentage gain.
*
* @return whether it has the percentage gain
*/
public boolean hasGainPercentage() {
return getGainPercentage() != null;
}
/**
* Returns the market value of the portfolio in the portfolio default
* currency.
*
* @return market value of the portfolio in the portfolio default currency
*/
public MarketValue getMarketValue() {
return getExtension(MarketValue.class);
}
/**
* Sets the market value of the portfolio in the portfolio default currency.
*
* @param marketValue market value of the portfolio in the portfolio default
* currency or <code>null</code> to reset
*/
public void setMarketValue(MarketValue marketValue) {
if (marketValue == null) {
removeExtension(MarketValue.class);
} else {
setExtension(marketValue);
}
}
/**
* Returns whether it has the market value of the portfolio in the portfolio
* default currency.
*
* @return whether it has the market value of the portfolio in the portfolio
* default currency
*/
public boolean hasMarketValue() {
return hasExtension(MarketValue.class);
}
/**
* Returns the 1 week return (percentage).
*
* @return 1 week return (percentage)
*/
public Double getReturn1w() {
return return1w;
}
/**
* Sets the 1 week return (percentage).
*
* @param return1w 1 week return (percentage) or <code>null</code> to reset
*/
public void setReturn1w(Double return1w) {
throwExceptionIfImmutable();
this.return1w = return1w;
}
/**
* Returns whether it has the 1 week return (percentage).
*
* @return whether it has the 1 week return (percentage)
*/
public boolean hasReturn1w() {
return getReturn1w() != null;
}
/**
* Returns the 1 year return (percentage).
*
* @return 1 year return (percentage)
*/
public Double getReturn1y() {
return return1y;
}
/**
* Sets the 1 year return (percentage).
*
* @param return1y 1 year return (percentage) or <code>null</code> to reset
*/
public void setReturn1y(Double return1y) {
throwExceptionIfImmutable();
this.return1y = return1y;
}
/**
* Returns whether it has the 1 year return (percentage).
*
* @return whether it has the 1 year return (percentage)
*/
public boolean hasReturn1y() {
return getReturn1y() != null;
}
/**
* Returns the 3 month return (percentage).
*
* @return 3 month return (percentage)
*/
public Double getReturn3m() {
return return3m;
}
/**
* Sets the 3 month return (percentage).
*
* @param return3m 3 month return (percentage) or <code>null</code> to reset
*/
public void setReturn3m(Double return3m) {
throwExceptionIfImmutable();
this.return3m = return3m;
}
/**
* Returns whether it has the 3 month return (percentage).
*
* @return whether it has the 3 month return (percentage)
*/
public boolean hasReturn3m() {
return getReturn3m() != null;
}
/**
* Returns the 3 year return (percentage).
*
* @return 3 year return (percentage)
*/
public Double getReturn3y() {
return return3y;
}
/**
* Sets the 3 year return (percentage).
*
* @param return3y 3 year return (percentage) or <code>null</code> to reset
*/
public void setReturn3y(Double return3y) {
throwExceptionIfImmutable();
this.return3y = return3y;
}
/**
* Returns whether it has the 3 year return (percentage).
*
* @return whether it has the 3 year return (percentage)
*/
public boolean hasReturn3y() {
return getReturn3y() != null;
}
/**
* Returns the 4 week return (percentage).
*
* @return 4 week return (percentage)
*/
public Double getReturn4w() {
return return4w;
}
/**
* Sets the 4 week return (percentage).
*
* @param return4w 4 week return (percentage) or <code>null</code> to reset
*/
public void setReturn4w(Double return4w) {
throwExceptionIfImmutable();
this.return4w = return4w;
}
/**
* Returns whether it has the 4 week return (percentage).
*
* @return whether it has the 4 week return (percentage)
*/
public boolean hasReturn4w() {
return getReturn4w() != null;
}
/**
* Returns the 5 year return (percentage).
*
* @return 5 year return (percentage)
*/
public Double getReturn5y() {
return return5y;
}
/**
* Sets the 5 year return (percentage).
*
* @param return5y 5 year return (percentage) or <code>null</code> to reset
*/
public void setReturn5y(Double return5y) {
throwExceptionIfImmutable();
this.return5y = return5y;
}
/**
* Returns whether it has the 5 year return (percentage).
*
* @return whether it has the 5 year return (percentage)
*/
public boolean hasReturn5y() {
return getReturn5y() != null;
}
/**
* Returns the overall return (percentage).
*
* @return overall return (percentage)
*/
public Double getReturnOverall() {
return returnOverall;
}
/**
* Sets the overall return (percentage).
*
* @param returnOverall overall return (percentage) or <code>null</code> to
* reset
*/
public void setReturnOverall(Double returnOverall) {
throwExceptionIfImmutable();
this.returnOverall = returnOverall;
}
/**
* Returns whether it has the overall return (percentage).
*
* @return whether it has the overall return (percentage)
*/
public boolean hasReturnOverall() {
return getReturnOverall() != null;
}
/**
* Returns the Year-to-date return (percentage).
*
* @return Year-to-date return (percentage)
*/
public Double getReturnYTD() {
return returnYTD;
}
/**
* Sets the Year-to-date return (percentage).
*
* @param returnYTD Year-to-date return (percentage) or <code>null</code> to
* reset
*/
public void setReturnYTD(Double returnYTD) {
throwExceptionIfImmutable();
this.returnYTD = returnYTD;
}
/**
* Returns whether it has the Year-to-date return (percentage).
*
* @return whether it has the Year-to-date return (percentage)
*/
public boolean hasReturnYTD() {
return getReturnYTD() != null;
}
@Override
protected void validate() {
}
/**
* Returns the extension description, specifying whether it is required, and
* whether it is repeatable.
*
* @param required whether it is required
* @param repeatable whether it is repeatable
* @return extension description
*/
public static ExtensionDescription getDefaultDescription(boolean required,
boolean repeatable) {
ExtensionDescription desc =
ExtensionDescription.getDefaultDescription(PortfolioData.class);
desc.setRequired(required);
desc.setRepeatable(repeatable);
return desc;
}
@Override
protected void putAttributes(AttributeGenerator generator) {
generator.put(CURRENCYCODE, currencyCode);
generator.put(GAINPERCENTAGE, gainPercentage);
generator.put(RETURN1W, return1w);
generator.put(RETURN1Y, return1y);
generator.put(RETURN3M, return3m);
generator.put(RETURN3Y, return3y);
generator.put(RETURN4W, return4w);
generator.put(RETURN5Y, return5y);
generator.put(RETURNOVERALL, returnOverall);
generator.put(RETURNYTD, returnYTD);
}
@Override
protected void consumeAttributes(AttributeHelper helper) throws ParseException
{
currencyCode = helper.consume(CURRENCYCODE, false);
gainPercentage = helper.consumeDouble(GAINPERCENTAGE, false);
return1w = helper.consumeDouble(RETURN1W, false);
return1y = helper.consumeDouble(RETURN1Y, false);
return3m = helper.consumeDouble(RETURN3M, false);
return3y = helper.consumeDouble(RETURN3Y, false);
return4w = helper.consumeDouble(RETURN4W, false);
return5y = helper.consumeDouble(RETURN5Y, false);
returnOverall = helper.consumeDouble(RETURNOVERALL, false);
returnYTD = helper.consumeDouble(RETURNYTD, false);
}
@Override
public String toString() {
return "{PortfolioData currencyCode=" + currencyCode + " gainPercentage=" +
gainPercentage + " return1w=" + return1w + " return1y=" + return1y +
" return3m=" + return3m + " return3y=" + return3y + " return4w=" +
return4w + " return5y=" + return5y + " returnOverall=" + returnOverall +
" returnYTD=" + returnYTD + "}";
}
}