1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.moneywise.data.basic;
18
19 import io.github.tonywasher.joceanus.metis.data.MetisDataDifference;
20 import io.github.tonywasher.joceanus.metis.data.MetisDataEditState;
21 import io.github.tonywasher.joceanus.metis.data.MetisDataItem.MetisDataFieldId;
22 import io.github.tonywasher.joceanus.metis.data.MetisDataResource;
23 import io.github.tonywasher.joceanus.metis.data.MetisDataState;
24 import io.github.tonywasher.joceanus.metis.field.MetisFieldItem;
25 import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
26 import io.github.tonywasher.joceanus.metis.field.MetisFieldVersionedSet;
27 import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWisePayeeInfo.MoneyWisePayeeInfoList;
28 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseAccountInfoClass;
29 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseAccountInfoType.MoneyWiseAccountInfoTypeList;
30 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWisePayeeClass;
31 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWisePayeeType;
32 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWisePayeeType.MoneyWisePayeeTypeList;
33 import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseStaticDataType;
34 import io.github.tonywasher.joceanus.moneywise.exc.MoneyWiseDataException;
35 import io.github.tonywasher.joceanus.moneywise.exc.MoneyWiseLogicException;
36 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
37 import io.github.tonywasher.joceanus.oceanus.format.OceanusDataFormatter;
38 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataInstanceMap;
39 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataItem;
40 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataMapItem;
41 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataResource;
42 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataSet;
43 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataValues;
44 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataValues.PrometheusInfoItem;
45 import io.github.tonywasher.joceanus.prometheus.data.PrometheusEncrypted.PrometheusDataInfoSetItemCtl;
46 import io.github.tonywasher.joceanus.prometheus.data.PrometheusListStyle;
47 import io.github.tonywasher.joceanus.prometheus.views.PrometheusEditSet;
48
49 import java.util.HashMap;
50 import java.util.Iterator;
51 import java.util.Map;
52
53
54
55
56 public class MoneyWisePayee
57 extends MoneyWiseAssetBase
58 implements PrometheusDataInfoSetItemCtl<MoneyWisePayeeInfo> {
59
60
61
62 public static final String OBJECT_NAME = MoneyWiseBasicDataType.PAYEE.getItemName();
63
64
65
66
67 public static final String LIST_NAME = MoneyWiseBasicDataType.PAYEE.getListName();
68
69
70
71
72 private static final MetisFieldVersionedSet<MoneyWisePayee> FIELD_DEFS = MetisFieldVersionedSet.newVersionedFieldSet(MoneyWisePayee.class);
73
74
75
76
77 static {
78 FIELD_DEFS.declareLocalField(PrometheusDataResource.DATAINFOSET_NAME, MoneyWisePayee::getInfoSet);
79 FIELD_DEFS.buildFieldMap(MoneyWiseAccountInfoClass.class, MoneyWisePayee::getFieldValue);
80 }
81
82
83
84
85 private final boolean hasInfoSet;
86
87
88
89
90 private final boolean useInfoSet;
91
92
93
94
95 private final MoneyWisePayeeInfoSet theInfoSet;
96
97
98
99
100
101
102
103 protected MoneyWisePayee(final MoneyWisePayeeList pList,
104 final MoneyWisePayee pPayee) {
105
106 super(pList, pPayee);
107
108
109 switch (getList().getStyle()) {
110 case EDIT:
111 theInfoSet = new MoneyWisePayeeInfoSet(this, pList.getActInfoTypes(), pList.getPayeeInfo());
112 theInfoSet.cloneDataInfoSet(pPayee.getInfoSet());
113 hasInfoSet = true;
114 useInfoSet = true;
115 break;
116 case CLONE, CORE:
117 theInfoSet = new MoneyWisePayeeInfoSet(this, pList.getActInfoTypes(), pList.getPayeeInfo());
118 hasInfoSet = true;
119 useInfoSet = false;
120 break;
121 default:
122 theInfoSet = null;
123 hasInfoSet = false;
124 useInfoSet = false;
125 break;
126 }
127 }
128
129
130
131
132
133
134
135
136 private MoneyWisePayee(final MoneyWisePayeeList pList,
137 final PrometheusDataValues pValues) throws OceanusException {
138
139 super(pList, pValues);
140
141
142 theInfoSet = new MoneyWisePayeeInfoSet(this, pList.getActInfoTypes(), pList.getPayeeInfo());
143 hasInfoSet = true;
144 useInfoSet = false;
145 }
146
147
148
149
150
151
152 public MoneyWisePayee(final MoneyWisePayeeList pList) {
153 super(pList);
154
155
156 theInfoSet = new MoneyWisePayeeInfoSet(this, pList.getActInfoTypes(), pList.getPayeeInfo());
157 hasInfoSet = true;
158 useInfoSet = true;
159 }
160
161 @Override
162 public MetisFieldSetDef getDataFieldSet() {
163 return FIELD_DEFS;
164 }
165
166 @Override
167 public boolean includeXmlField(final MetisDataFieldId pField) {
168
169 if (MoneyWiseBasicResource.CATEGORY_NAME.equals(pField)) {
170 return true;
171 }
172
173
174 return super.includeXmlField(pField);
175 }
176
177 @Override
178 public Long getExternalId() {
179 return MoneyWiseAssetType.createExternalId(MoneyWiseAssetType.PAYEE, getIndexedId());
180 }
181
182 @Override
183 public MoneyWisePayeeInfoSet getInfoSet() {
184 return theInfoSet;
185 }
186
187
188
189
190
191
192
193 private Object getFieldValue(final MetisDataFieldId pFieldId) {
194 return theInfoSet != null ? theInfoSet.getFieldValue(pFieldId) : null;
195 }
196
197
198
199
200
201
202 public char[] getWebSite() {
203 return hasInfoSet
204 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.WEBSITE, char[].class)
205 : null;
206 }
207
208
209
210
211
212
213 public char[] getCustNo() {
214 return hasInfoSet
215 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.CUSTOMERNO, char[].class)
216 : null;
217 }
218
219
220
221
222
223
224 public char[] getUserId() {
225 return hasInfoSet
226 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.USERID, char[].class)
227 : null;
228 }
229
230
231
232
233
234
235 public char[] getPassword() {
236 return hasInfoSet
237 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.PASSWORD, char[].class)
238 : null;
239 }
240
241
242
243
244
245
246 public char[] getSortCode() {
247 return hasInfoSet
248 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.SORTCODE, char[].class)
249 : null;
250 }
251
252
253
254
255
256
257 public char[] getReference() {
258 return hasInfoSet
259 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.REFERENCE, char[].class)
260 : null;
261 }
262
263
264
265
266
267
268 public char[] getAccount() {
269 return hasInfoSet
270 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.ACCOUNT, char[].class)
271 : null;
272 }
273
274
275
276
277
278
279 public char[] getNotes() {
280 return hasInfoSet
281 ? theInfoSet.getValue(MoneyWiseAccountInfoClass.NOTES, char[].class)
282 : null;
283 }
284
285 @Override
286 public MoneyWisePayeeType getCategory() {
287 return getValues().getValue(MoneyWiseBasicResource.CATEGORY_NAME, MoneyWisePayeeType.class);
288 }
289
290
291
292
293
294
295 public Integer getCategoryId() {
296 final MoneyWisePayeeType myType = getCategory();
297 return (myType == null)
298 ? null
299 : myType.getIndexedId();
300 }
301
302
303
304
305
306
307 public String getCategoryName() {
308 final MoneyWisePayeeType myType = getCategory();
309 return myType == null
310 ? null
311 : myType.getName();
312 }
313
314
315
316
317
318
319 public MoneyWisePayeeClass getCategoryClass() {
320 final MoneyWisePayeeType myType = getCategory();
321 return (myType == null)
322 ? null
323 : myType.getPayeeClass();
324 }
325
326 @Override
327 public MoneyWisePayee getBase() {
328 return (MoneyWisePayee) super.getBase();
329 }
330
331 @Override
332 public MoneyWisePayeeList getList() {
333 return (MoneyWisePayeeList) super.getList();
334 }
335
336 @Override
337 public MetisDataState getState() {
338
339 MetisDataState myState = super.getState();
340
341
342 if ((myState == MetisDataState.CLEAN) && useInfoSet) {
343
344 myState = theInfoSet.getState();
345 }
346
347
348 return myState;
349 }
350
351 @Override
352 public MetisDataEditState getEditState() {
353
354 MetisDataEditState myState = super.getEditState();
355
356
357 if (myState == MetisDataEditState.CLEAN
358 && useInfoSet) {
359
360 myState = theInfoSet.getEditState();
361 }
362
363
364 return myState;
365 }
366
367 @Override
368 public boolean hasHistory() {
369
370 boolean hasHistory = super.hasHistory();
371
372
373 if (!hasHistory && useInfoSet) {
374
375 hasHistory = theInfoSet.hasHistory();
376 }
377
378
379 return hasHistory;
380 }
381
382 @Override
383 public void pushHistory() {
384
385 super.pushHistory();
386
387
388 if (useInfoSet) {
389
390 theInfoSet.pushHistory();
391 }
392 }
393
394 @Override
395 public void popHistory() {
396
397 super.popHistory();
398
399
400 if (useInfoSet) {
401
402 theInfoSet.popHistory();
403 }
404 }
405
406 @Override
407 public boolean checkForHistory() {
408
409 boolean bChanges = super.checkForHistory();
410
411
412 if (useInfoSet) {
413
414 bChanges |= theInfoSet.checkForHistory();
415 }
416
417
418 return bChanges;
419 }
420
421 @Override
422 public MetisDataDifference fieldChanged(final MetisDataFieldId pField) {
423
424 final MoneyWiseAccountInfoClass myClass = MoneyWisePayeeInfoSet.getClassForField(pField);
425 if (myClass != null) {
426 return useInfoSet
427 ? theInfoSet.fieldChanged(myClass)
428 : MetisDataDifference.IDENTICAL;
429 }
430
431
432 return super.fieldChanged(pField);
433 }
434
435 @Override
436 public void setDeleted(final boolean bDeleted) {
437
438 if (useInfoSet) {
439 theInfoSet.setDeleted(bDeleted);
440 }
441
442
443 super.setDeleted(bDeleted);
444 }
445
446
447
448
449
450
451
452 public boolean isPayeeClass(final MoneyWisePayeeClass pClass) {
453
454 return getCategoryClass() == pClass;
455 }
456
457
458
459
460
461
462 @Override
463 public boolean isHidden() {
464 final MoneyWisePayeeClass myClass = this.getCategoryClass();
465 return myClass != null
466 && myClass.isHiddenType();
467 }
468
469
470
471
472
473
474 public void setDefaults() throws OceanusException {
475 getList().getValidator().setDefaults(this);
476 }
477
478 @Override
479 public int compareValues(final PrometheusDataItem pThat) {
480
481 final MoneyWisePayee myThat = (MoneyWisePayee) pThat;
482 int iDiff = MetisDataDifference.compareObject(getCategory(), myThat.getCategory());
483 if (iDiff == 0) {
484 iDiff = MetisDataDifference.compareObject(getName(), myThat.getName());
485 }
486 return iDiff;
487 }
488
489 @Override
490 public void resolveDataSetLinks() throws OceanusException {
491
492 super.resolveDataSetLinks();
493
494
495 resolveDataLink(MoneyWiseBasicResource.CATEGORY_NAME, MoneyWiseStaticDataType.PAYEETYPE);
496 }
497
498 @Override
499 protected void resolveEditSetLinks() throws OceanusException {
500
501 final PrometheusEditSet myEditSet = getList().getEditSet();
502
503
504 if (myEditSet.hasDataType(MoneyWiseStaticDataType.PAYEETYPE)) {
505 resolveDataLink(MoneyWiseBasicResource.CATEGORY_NAME, myEditSet.getDataList(MoneyWiseStaticDataType.PAYEETYPE, MoneyWisePayeeTypeList.class));
506 }
507
508
509 theInfoSet.resolveEditSetLinks(myEditSet);
510 }
511
512
513
514
515
516
517
518 public void setWebSite(final char[] pWebSite) throws OceanusException {
519 setInfoSetValue(MoneyWiseAccountInfoClass.WEBSITE, pWebSite);
520 }
521
522
523
524
525
526
527
528 public void setCustNo(final char[] pCustNo) throws OceanusException {
529 setInfoSetValue(MoneyWiseAccountInfoClass.CUSTOMERNO, pCustNo);
530 }
531
532
533
534
535
536
537
538 public void setUserId(final char[] pUserId) throws OceanusException {
539 setInfoSetValue(MoneyWiseAccountInfoClass.USERID, pUserId);
540 }
541
542
543
544
545
546
547
548 public void setPassword(final char[] pPassword) throws OceanusException {
549 setInfoSetValue(MoneyWiseAccountInfoClass.PASSWORD, pPassword);
550 }
551
552
553
554
555
556
557
558 public void setSortCode(final char[] pSortCode) throws OceanusException {
559 setInfoSetValue(MoneyWiseAccountInfoClass.SORTCODE, pSortCode);
560 }
561
562
563
564
565
566
567
568 public void setAccount(final char[] pAccount) throws OceanusException {
569 setInfoSetValue(MoneyWiseAccountInfoClass.ACCOUNT, pAccount);
570 }
571
572
573
574
575
576
577
578 public void setReference(final char[] pReference) throws OceanusException {
579 setInfoSetValue(MoneyWiseAccountInfoClass.REFERENCE, pReference);
580 }
581
582
583
584
585
586
587
588 public void setNotes(final char[] pNotes) throws OceanusException {
589 setInfoSetValue(MoneyWiseAccountInfoClass.NOTES, pNotes);
590 }
591
592
593
594
595
596
597
598
599 private void setInfoSetValue(final MoneyWiseAccountInfoClass pInfoClass,
600 final Object pValue) throws OceanusException {
601
602 if (!hasInfoSet) {
603 throw new MoneyWiseLogicException(ERROR_BADINFOSET);
604 }
605
606
607 theInfoSet.setValue(pInfoClass, pValue);
608 }
609
610 @Override
611 public void touchUnderlyingItems() {
612
613 getCategory().touchItem(this);
614
615
616 theInfoSet.touchUnderlyingItems();
617 }
618
619 @Override
620 public void touchOnUpdate() {
621
622 clearTouches(MoneyWiseBasicDataType.CASHINFO);
623 clearTouches(MoneyWiseBasicDataType.SECURITY);
624 clearTouches(MoneyWiseBasicDataType.DEPOSIT);
625 clearTouches(MoneyWiseBasicDataType.LOAN);
626 clearTouches(MoneyWiseBasicDataType.PORTFOLIO);
627 }
628
629
630
631
632
633
634
635 @Override
636 public boolean applyChanges(final PrometheusDataItem pPayee) {
637
638 if (!(pPayee instanceof MoneyWisePayee myPayee)) {
639 return false;
640 }
641
642
643 pushHistory();
644
645
646 applyBasicChanges(myPayee);
647
648
649 return checkForHistory();
650 }
651
652 @Override
653 public void adjustMapForItem() {
654 final MoneyWisePayeeList myList = getList();
655 final MoneyWisePayeeDataMap myMap = myList.getDataMap();
656 myMap.adjustForItem(this);
657 }
658
659 @Override
660 public void removeItem() {
661 theInfoSet.removeItems();
662 super.removeItem();
663 }
664
665
666
667
668 public static class MoneyWisePayeeList
669 extends MoneyWiseAssetBaseList<MoneyWisePayee> {
670
671
672
673 private static final MetisFieldSet<MoneyWisePayeeList> FIELD_DEFS = MetisFieldSet.newFieldSet(MoneyWisePayeeList.class);
674
675
676
677
678 private MoneyWisePayeeInfoList theInfoList;
679
680
681
682
683 private MoneyWiseAccountInfoTypeList theInfoTypeList;
684
685
686
687
688
689
690 public MoneyWisePayeeList(final PrometheusDataSet pData) {
691 super(pData, MoneyWisePayee.class, MoneyWiseBasicDataType.PAYEE);
692 }
693
694
695
696
697
698
699 protected MoneyWisePayeeList(final MoneyWisePayeeList pSource) {
700 super(pSource);
701 }
702
703 @Override
704 public MetisFieldSet<MoneyWisePayeeList> getDataFieldSet() {
705 return FIELD_DEFS;
706 }
707
708 @Override
709 public String listName() {
710 return LIST_NAME;
711 }
712
713 @Override
714 public MetisFieldSetDef getItemFields() {
715 return MoneyWisePayee.FIELD_DEFS;
716 }
717
718 @Override
719 public MoneyWisePayeeDataMap getDataMap() {
720 return (MoneyWisePayeeDataMap) super.getDataMap();
721 }
722
723
724
725
726
727
728 public MoneyWisePayeeInfoList getPayeeInfo() {
729 if (theInfoList == null) {
730 theInfoList = getDataSet().getDataList(MoneyWiseBasicDataType.PAYEEINFO, MoneyWisePayeeInfoList.class);
731 }
732 return theInfoList;
733 }
734
735
736
737
738
739
740 public MoneyWiseAccountInfoTypeList getActInfoTypes() {
741 if (theInfoTypeList == null) {
742 theInfoTypeList = getEditSet() == null
743 ? getDataSet().getDataList(MoneyWiseStaticDataType.ACCOUNTINFOTYPE, MoneyWiseAccountInfoTypeList.class)
744 : getEditSet().getDataList(MoneyWiseStaticDataType.ACCOUNTINFOTYPE, MoneyWiseAccountInfoTypeList.class);
745 }
746 return theInfoTypeList;
747 }
748
749 @Override
750 protected MoneyWisePayeeList getEmptyList(final PrometheusListStyle pStyle) {
751 final MoneyWisePayeeList myList = new MoneyWisePayeeList(this);
752 myList.setStyle(pStyle);
753 return myList;
754 }
755
756
757
758
759
760
761
762
763 public MoneyWisePayeeList deriveEditList(final PrometheusEditSet pEditSet) throws OceanusException {
764
765 final MoneyWisePayeeList myList = getEmptyList(PrometheusListStyle.EDIT);
766 myList.ensureMap();
767 pEditSet.setEditEntryList(MoneyWiseBasicDataType.PAYEE, myList);
768 myList.getValidator().setEditSet(pEditSet);
769
770
771 myList.theInfoTypeList = pEditSet.getDataList(MoneyWiseStaticDataType.ACCOUNTINFOTYPE, MoneyWiseAccountInfoTypeList.class);
772
773
774 final MoneyWisePayeeInfoList myPayeeInfo = getPayeeInfo();
775 myList.theInfoList = myPayeeInfo.getEmptyList(PrometheusListStyle.EDIT);
776 pEditSet.setEditEntryList(MoneyWiseBasicDataType.PAYEEINFO, myList.theInfoList);
777
778
779 myList.setEditSet(pEditSet);
780
781
782 final Iterator<MoneyWisePayee> myIterator = iterator();
783 while (myIterator.hasNext()) {
784 final MoneyWisePayee myCurr = myIterator.next();
785
786
787 if (myCurr.isDeleted()) {
788 continue;
789 }
790
791
792 final MoneyWisePayee myPayee = new MoneyWisePayee(myList, myCurr);
793 myList.add(myPayee);
794 myPayee.resolveEditSetLinks();
795
796
797 myPayee.adjustMapForItem();
798 }
799
800
801 return myList;
802 }
803
804 @Override
805 public MoneyWisePayee findItemByName(final String pName) {
806
807 return getDataMap().findItemByName(pName);
808 }
809
810 @Override
811 public boolean checkAvailableName(final String pName) {
812
813 return findItemByName(pName) == null;
814 }
815
816 @Override
817 public boolean validNameCount(final String pName) {
818
819 return getDataMap().validNameCount(pName);
820 }
821
822
823
824
825
826
827
828 @Override
829 public MoneyWisePayee addCopyItem(final PrometheusDataItem pPayee) {
830
831 if (!(pPayee instanceof MoneyWisePayee)) {
832 throw new UnsupportedOperationException();
833 }
834
835 final MoneyWisePayee myPayee = new MoneyWisePayee(this, (MoneyWisePayee) pPayee);
836 add(myPayee);
837 return myPayee;
838 }
839
840
841
842
843
844
845 @Override
846 public MoneyWisePayee addNewItem() {
847 final MoneyWisePayee myPayee = new MoneyWisePayee(this);
848 add(myPayee);
849 return myPayee;
850 }
851
852
853
854
855
856
857
858 public MoneyWisePayee getSingularClass(final MoneyWisePayeeClass pClass) {
859
860 return getDataMap().findSingularItem(pClass);
861 }
862
863 @Override
864 public MoneyWisePayee addValuesItem(final PrometheusDataValues pValues) throws OceanusException {
865
866 final MoneyWisePayee myPayee = new MoneyWisePayee(this, pValues);
867
868
869 if (!isIdUnique(myPayee.getIndexedId())) {
870 myPayee.addError(ERROR_DUPLICATE, MetisDataResource.DATA_ID);
871 throw new MoneyWiseDataException(myPayee, ERROR_VALIDATION);
872 }
873
874
875 add(myPayee);
876
877
878 if (pValues.hasInfoItems()) {
879
880 final Iterator<PrometheusInfoItem> myIterator = pValues.infoIterator();
881 while (myIterator.hasNext()) {
882 final PrometheusInfoItem myItem = myIterator.next();
883
884
885 final PrometheusDataValues myValues = myItem.getValues(myPayee);
886 theInfoList.addValuesItem(myValues);
887 }
888 }
889
890
891 return myPayee;
892 }
893
894 @Override
895 protected MoneyWisePayeeDataMap allocateDataMap() {
896 return new MoneyWisePayeeDataMap();
897 }
898
899 @Override
900 public void postProcessOnLoad() throws OceanusException {
901
902 super.resolveDataSetLinks();
903 reSort();
904 }
905 }
906
907
908
909
910 public static class MoneyWisePayeeDataMap
911 implements PrometheusDataMapItem, MetisFieldItem {
912
913
914
915 private static final MetisFieldSet<MoneyWisePayeeDataMap> FIELD_DEFS = MetisFieldSet.newFieldSet(MoneyWisePayeeDataMap.class);
916
917
918
919
920 static {
921 FIELD_DEFS.declareLocalField(MoneyWiseBasicResource.MONEYWISEDATA_MAP_UNDERLYING, MoneyWisePayeeDataMap::getUnderlyingMap);
922 FIELD_DEFS.declareLocalField(MoneyWiseBasicResource.MONEYWISEDATA_MAP_SINGULARMAP, MoneyWisePayeeDataMap::getPayeeMap);
923 FIELD_DEFS.declareLocalField(MoneyWiseBasicResource.MONEYWISEDATA_MAP_SINGULARCOUNTS, MoneyWisePayeeDataMap::getPayeeCountMap);
924 }
925
926
927
928
929 private final MoneyWiseAssetDataMap theUnderlyingMap;
930
931
932
933
934 private final Map<Integer, Integer> thePayeeCountMap;
935
936
937
938
939 private final Map<Integer, MoneyWisePayee> thePayeeMap;
940
941
942
943
944 public MoneyWisePayeeDataMap() {
945
946 theUnderlyingMap = new MoneyWiseAssetDataMap();
947
948
949 thePayeeCountMap = new HashMap<>();
950 thePayeeMap = new HashMap<>();
951 }
952
953 @Override
954 public MetisFieldSet<MoneyWisePayeeDataMap> getDataFieldSet() {
955 return FIELD_DEFS;
956 }
957
958 @Override
959 public String formatObject(final OceanusDataFormatter pFormatter) {
960 return FIELD_DEFS.getName();
961 }
962
963
964
965
966
967
968 public MoneyWiseAssetDataMap getUnderlyingMap() {
969 return theUnderlyingMap;
970 }
971
972
973
974
975
976
977 private Map<Integer, MoneyWisePayee> getPayeeMap() {
978 return thePayeeMap;
979 }
980
981
982
983
984
985
986 private Map<Integer, Integer> getPayeeCountMap() {
987 return thePayeeCountMap;
988 }
989
990 @Override
991 public void resetMap() {
992 theUnderlyingMap.resetMap();
993 thePayeeCountMap.clear();
994 thePayeeMap.clear();
995 }
996
997 @Override
998 public void adjustForItem(final PrometheusDataItem pItem) {
999
1000 final MoneyWisePayee myItem = (MoneyWisePayee) pItem;
1001
1002
1003 final MoneyWisePayeeClass myClass = myItem.getCategoryClass();
1004 if (myClass.isSingular()) {
1005
1006 final Integer myId = myClass.getClassId();
1007 final Integer myCount = thePayeeCountMap.get(myId);
1008 if (myCount == null) {
1009 thePayeeCountMap.put(myId, PrometheusDataInstanceMap.ONE);
1010 } else {
1011 thePayeeCountMap.put(myId, myCount + 1);
1012 }
1013
1014
1015 thePayeeMap.put(myId, myItem);
1016 }
1017
1018
1019 theUnderlyingMap.adjustForItem(pItem);
1020 }
1021
1022
1023
1024
1025
1026
1027
1028 public MoneyWisePayee findItemByName(final String pName) {
1029 final MoneyWiseAssetBase myAsset = theUnderlyingMap.findAssetByName(pName);
1030 return myAsset instanceof MoneyWisePayee myPayee
1031 ? myPayee
1032 : null;
1033 }
1034
1035
1036
1037
1038
1039
1040
1041 public boolean validNameCount(final String pName) {
1042 return theUnderlyingMap.validKeyCount(pName);
1043 }
1044
1045
1046
1047
1048
1049
1050
1051 public boolean availableName(final String pName) {
1052 return theUnderlyingMap.availableKey(pName);
1053 }
1054
1055
1056
1057
1058
1059
1060
1061 public MoneyWisePayee findSingularItem(final MoneyWisePayeeClass pClass) {
1062 return thePayeeMap.get(pClass.getClassId());
1063 }
1064
1065
1066
1067
1068
1069
1070
1071 public boolean validSingularCount(final MoneyWisePayeeClass pClass) {
1072 final Integer myResult = thePayeeCountMap.get(pClass.getClassId());
1073 return PrometheusDataInstanceMap.ONE.equals(myResult);
1074 }
1075 }
1076 }