Total Pageviews

2011/06/10

利用Commons Lang API 來提升Code Coverage

Problem
目前參與的專案,對於code coverage有相當嚴苛的規定(at least 80%),在進行測試的時候,發現由Eclipse產生的equals()與hashCode()此二method是無法提升到80%以上的主因,因為裡頭太多的if-else statement,如下:
  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
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
   @Override
   public int hashCode() {
       final int prime = 31;
       int result = super.hashCode();
       result = prime * result + ((acsNo == null) ? 0 : acsNo.hashCode());
       result = prime * result +
           ((addrHsnNm == null) ? 0 : addrHsnNm.hashCode());
       result = prime * result + ((addrLin == null) ? 0 : addrLin.hashCode());
       result = prime * result + ((addrMk == null) ? 0 : addrMk.hashCode());
       result = prime * result +
           ((addrRoadNo == null) ? 0 : addrRoadNo.hashCode());
       result = prime * result +
           ((addrTownNm == null) ? 0 : addrTownNm.hashCode());
       result = prime * result +
           ((addrVillNm == null) ? 0 : addrVillNm.hashCode());
       result = prime * result +
           ((admRmdDate == null) ? 0 : admRmdDate.hashCode());
       result = prime * result +
           ((admRmdStus == null) ? 0 : admRmdStus.hashCode());
       result = prime * result +
           ((adtSgstMk == null) ? 0 : adtSgstMk.hashCode());
       result = prime * result +
           ((adtrAplTp == null) ? 0 : adtrAplTp.hashCode());
       result = prime * result +
           ((adtrFnshDate == null) ? 0 : adtrFnshDate.hashCode());
       result = prime * result +
           ((aplLimitYm == null) ? 0 : aplLimitYm.hashCode());
       result = prime * result +
           ((arrgMtgTp == null) ? 0 : arrgMtgTp.hashCode());
       result = prime * result + ((asgKey == null) ? 0 : asgKey.hashCode());
       result = prime * result + ((asgMk == null) ? 0 : asgMk.hashCode());
       result = prime * result + ((asst1 == null) ? 0 : asst1.hashCode());
       result = prime * result + ((asst2 == null) ? 0 : asst2.hashCode());
       result = prime * result + ((asst3 == null) ? 0 : asst3.hashCode());
       result = prime * result +
           ((asstCdcChar1 == null) ? 0 : asstCdcChar1.hashCode());
       result = prime * result +
           ((asstCdcChar2 == null) ? 0 : asstCdcChar2.hashCode());
       result = prime * result +
           ((asstCdcChar3 == null) ? 0 : asstCdcChar3.hashCode());
       result = prime * result +
           ((asstCdcDate1 == null) ? 0 : asstCdcDate1.hashCode());
       result = prime * result +
           ((asstCdcDate2 == null) ? 0 : asstCdcDate2.hashCode());
       result = prime * result +
           ((asstCdcDate3 == null) ? 0 : asstCdcDate3.hashCode());
       result = prime * result +
           ((asstCdcNo1 == null) ? 0 : asstCdcNo1.hashCode());
       result = prime * result +
           ((asstCdcNo2 == null) ? 0 : asstCdcNo2.hashCode());
       result = prime * result +
           ((asstCdcNo3 == null) ? 0 : asstCdcNo3.hashCode());
       result = prime * result + ((asstTp == null) ? 0 : asstTp.hashCode());
       result = prime * result + ((authMk == null) ? 0 : authMk.hashCode());
       result = prime * result +
           ((baTaxKey == null) ? 0 : baTaxKey.hashCode());
       result = prime * result + ((baTaxMk == null) ? 0 : baTaxMk.hashCode());
       result = prime * result + ((ban == null) ? 0 : ban.hashCode());
       result = prime * result + ((behAmt == null) ? 0 : behAmt.hashCode());
       result = prime * result + ((bhvAmt == null) ? 0 : bhvAmt.hashCode());
       result = prime * result + ((bhvAmt1 == null) ? 0 : bhvAmt1.hashCode());
       result = prime * result + ((bhvAmt2 == null) ? 0 : bhvAmt2.hashCode());
       result = prime * result + ((bhvAmt3 == null) ? 0 : bhvAmt3.hashCode());
       result = prime * result + ((bhvAmt4 == null) ? 0 : bhvAmt4.hashCode());
       result = prime * result +
           ((bhvArtc1 == null) ? 0 : bhvArtc1.hashCode());
       result = prime * result +
           ((bhvArtc2 == null) ? 0 : bhvArtc2.hashCode());
       result = prime * result +
           ((bhvArtc3 == null) ? 0 : bhvArtc3.hashCode());
       result = prime * result +
           ((bhvArtc4 == null) ? 0 : bhvArtc4.hashCode());
       result = prime * result +
           ((billUnit == null) ? 0 : billUnit.hashCode());
       result = prime * result +
           ((carryDate == null) ? 0 : carryDate.hashCode());
       result = prime * result +
           ((carrySeqNo == null) ? 0 : carrySeqNo.hashCode());
       result = prime * result + ((caseTp == null) ? 0 : caseTp.hashCode());
       result = prime * result + ((chkUnit == null) ? 0 : chkUnit.hashCode());
       result = prime * result +
           ((collUnit == null) ? 0 : collUnit.hashCode());
       result = prime * result + ((cpt == null) ? 0 : cpt.hashCode());
       result = prime * result +
           ((cptCdcChar == null) ? 0 : cptCdcChar.hashCode());
       result = prime * result +
           ((cptCdcDate == null) ? 0 : cptCdcDate.hashCode());
       result = prime * result +
           ((cptCdcNo == null) ? 0 : cptCdcNo.hashCode());
       result = prime * result +
           ((createDate == null) ? 0 : createDate.hashCode());
       result = prime * result +
           ((crmlArtc == null) ? 0 : crmlArtc.hashCode());
       result = prime * result +
           ((crmlProcDate == null) ? 0 : crmlProcDate.hashCode());
       result = prime * result +
           ((crmlStus == null) ? 0 : crmlStus.hashCode());
       result = prime * result +
           ((evadeIncm == null) ? 0 : evadeIncm.hashCode());
       result = prime * result +
           ((evadeTax == null) ? 0 : evadeTax.hashCode());
       result = prime * result + ((evdAmt1 == null) ? 0 : evdAmt1.hashCode());
       result = prime * result + ((evdAmt2 == null) ? 0 : evdAmt2.hashCode());
       result = prime * result + ((evdAmt3 == null) ? 0 : evdAmt3.hashCode());
       result = prime * result + ((evdAmt4 == null) ? 0 : evdAmt4.hashCode());
       result = prime * result +
           ((evdArtc1 == null) ? 0 : evdArtc1.hashCode());
       result = prime * result +
           ((evdArtc2 == null) ? 0 : evdArtc2.hashCode());
       result = prime * result +
           ((evdArtc3 == null) ? 0 : evdArtc3.hashCode());
       result = prime * result +
           ((evdArtc4 == null) ? 0 : evdArtc4.hashCode());
       result = prime * result +
           ((extdReas == null) ? 0 : extdReas.hashCode());
       result = prime * result + ((extdTms == null) ? 0 : extdTms.hashCode());
       result = prime * result + ((fCnvtMk == null) ? 0 : fCnvtMk.hashCode());
       result = prime * result +
           ((fineAmtTot == null) ? 0 : fineAmtTot.hashCode());
       result = prime * result +
           ((fshAplTp == null) ? 0 : fshAplTp.hashCode());
       result = prime * result + ((fshDate == null) ? 0 : fshDate.hashCode());
       result = prime * result + ((id == null) ? 0 : id.hashCode());
       result = prime * result + ((invs1 == null) ? 0 : invs1.hashCode());
       result = prime * result + ((invs2 == null) ? 0 : invs2.hashCode());
       result = prime * result +
           ((invsRatio1 == null) ? 0 : invsRatio1.hashCode());
       result = prime * result +
           ((invsRatio2 == null) ? 0 : invsRatio2.hashCode());
       result = prime * result + ((madtrCd == null) ? 0 : madtrCd.hashCode());
       result = prime * result +
           ((manageCd == null) ? 0 : manageCd.hashCode());
       result = prime * result + ((npnshCd == null) ? 0 : npnshCd.hashCode());
       result = prime * result +
           ((npnshReas == null) ? 0 : npnshReas.hashCode());
       result = prime * result + ((oAdtrCd == null) ? 0 : oAdtrCd.hashCode());
       result = prime * result +
           ((oAsgDate == null) ? 0 : oAsgDate.hashCode());
       result = prime * result +
           ((oShFshDate == null) ? 0 : oShFshDate.hashCode());
       result = prime * result +
           ((ovpnshMk == null) ? 0 : ovpnshMk.hashCode());
       result = prime * result +
           ((pnshPrMk == null) ? 0 : pnshPrMk.hashCode());
       result = prime * result + ((pnshTp == null) ? 0 : pnshTp.hashCode());
       result = prime * result +
           ((prstAdtrCd == null) ? 0 : prstAdtrCd.hashCode());
       result = prime * result +
           ((prstAsgDate == null) ? 0 : prstAsgDate.hashCode());
       result = prime * result +
           ((prstPrcdDate == null) ? 0 : prstPrcdDate.hashCode());
       result = prime * result +
           ((prstPrcdStus == null) ? 0 : prstPrcdStus.hashCode());
       result = prime * result +
           ((prstShFshDate == null) ? 0 : prstShFshDate.hashCode());
       result = prime * result +
           ((reChkUnit == null) ? 0 : reChkUnit.hashCode());
       result = prime * result + ((respIdn == null) ? 0 : respIdn.hashCode());
       result = prime * result + ((respNm == null) ? 0 : respNm.hashCode());
       result = prime * result + ((revoCd == null) ? 0 : revoCd.hashCode());
       result = prime * result +
           ((seizeDate == null) ? 0 : seizeDate.hashCode());
       result = prime * result +
           ((servArea == null) ? 0 : servArea.hashCode());
       result = prime * result +
           ((subtaxCd == null) ? 0 : subtaxCd.hashCode());
       result = prime * result +
           ((timeStamp == null) ? 0 : timeStamp.hashCode());
       result = prime * result + ((townCd == null) ? 0 : townCd.hashCode());
       result = prime * result + ((trstrCd == null) ? 0 : trstrCd.hashCode());
       result = prime * result +
           ((updJdgfDate == null) ? 0 : updJdgfDate.hashCode());
       result = prime * result +
           ((updJdgfStus == null) ? 0 : updJdgfStus.hashCode());
       result = prime * result +
           ((updateDate == null) ? 0 : updateDate.hashCode());
       result = prime * result +
           ((updateUserCd == null) ? 0 : updateUserCd.hashCode());
       result = prime * result +
           ((urgtLmtDate == null) ? 0 : urgtLmtDate.hashCode());
       result = prime * result +
           ((vioBDate == null) ? 0 : vioBDate.hashCode());
       result = prime * result +
           ((vioEDate == null) ? 0 : vioEDate.hashCode());
       result = prime * result +
           ((vioFactCd1 == null) ? 0 : vioFactCd1.hashCode());
       result = prime * result +
           ((vioFactCd2 == null) ? 0 : vioFactCd2.hashCode());
       result = prime * result +
           ((vioHostIdnBan == null) ? 0 : vioHostIdnBan.hashCode());
       result = prime * result +
           ((vioHostNm == null) ? 0 : vioHostNm.hashCode());
       result = prime * result + ((vioYr == null) ? 0 : vioYr.hashCode());
       result = prime * result +
           ((ynArrgMtg == null) ? 0 : ynArrgMtg.hashCode());
       result = prime * result + ((zipCd == null) ? 0 : zipCd.hashCode());
       return result;
   }
   
   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       Nigt001 other = (Nigt001) obj;
       if (acsNo == null) {
           if (other.acsNo != null)
               return false;
       } else if (!acsNo.equals(other.acsNo))
           return false;
       if (addrHsnNm == null) {
           if (other.addrHsnNm != null)
               return false;
       } else if (!addrHsnNm.equals(other.addrHsnNm))
           return false;
       if (addrLin == null) {
           if (other.addrLin != null)
               return false;
       } else if (!addrLin.equals(other.addrLin))
           return false;
       if (addrMk == null) {
           if (other.addrMk != null)
               return false;
       } else if (!addrMk.equals(other.addrMk))
           return false;
       if (addrRoadNo == null) {
           if (other.addrRoadNo != null)
               return false;
       } else if (!addrRoadNo.equals(other.addrRoadNo))
           return false;
       if (addrTownNm == null) {
           if (other.addrTownNm != null)
               return false;
       } else if (!addrTownNm.equals(other.addrTownNm))
           return false;
       if (addrVillNm == null) {
           if (other.addrVillNm != null)
               return false;
       } else if (!addrVillNm.equals(other.addrVillNm))
           return false;
       if (admRmdDate == null) {
           if (other.admRmdDate != null)
               return false;
       } else if (!admRmdDate.equals(other.admRmdDate))
           return false;
       if (admRmdStus == null) {
           if (other.admRmdStus != null)
               return false;
       } else if (!admRmdStus.equals(other.admRmdStus))
           return false;
       if (adtSgstMk == null) {
           if (other.adtSgstMk != null)
               return false;
       } else if (!adtSgstMk.equals(other.adtSgstMk))
           return false;
       if (adtrAplTp == null) {
           if (other.adtrAplTp != null)
               return false;
       } else if (!adtrAplTp.equals(other.adtrAplTp))
           return false;
       if (adtrFnshDate == null) {
           if (other.adtrFnshDate != null)
               return false;
       } else if (!adtrFnshDate.equals(other.adtrFnshDate))
           return false;
       if (aplLimitYm == null) {
           if (other.aplLimitYm != null)
               return false;
       } else if (!aplLimitYm.equals(other.aplLimitYm))
           return false;
       if (arrgMtgTp == null) {
           if (other.arrgMtgTp != null)
               return false;
       } else if (!arrgMtgTp.equals(other.arrgMtgTp))
           return false;
       if (asgKey == null) {
           if (other.asgKey != null)
               return false;
       } else if (!asgKey.equals(other.asgKey))
           return false;
       if (asgMk == null) {
           if (other.asgMk != null)
               return false;
       } else if (!asgMk.equals(other.asgMk))
           return false;
       if (asst1 == null) {
           if (other.asst1 != null)
               return false;
       } else if (!asst1.equals(other.asst1))
           return false;
       if (asst2 == null) {
           if (other.asst2 != null)
               return false;
       } else if (!asst2.equals(other.asst2))
           return false;
       if (asst3 == null) {
           if (other.asst3 != null)
               return false;
       } else if (!asst3.equals(other.asst3))
           return false;
       if (asstCdcChar1 == null) {
           if (other.asstCdcChar1 != null)
               return false;
       } else if (!asstCdcChar1.equals(other.asstCdcChar1))
           return false;
       if (asstCdcChar2 == null) {
           if (other.asstCdcChar2 != null)
               return false;
       } else if (!asstCdcChar2.equals(other.asstCdcChar2))
           return false;
       if (asstCdcChar3 == null) {
           if (other.asstCdcChar3 != null)
               return false;
       } else if (!asstCdcChar3.equals(other.asstCdcChar3))
           return false;
       if (asstCdcDate1 == null) {
           if (other.asstCdcDate1 != null)
               return false;
       } else if (!asstCdcDate1.equals(other.asstCdcDate1))
           return false;
       if (asstCdcDate2 == null) {
           if (other.asstCdcDate2 != null)
               return false;
       } else if (!asstCdcDate2.equals(other.asstCdcDate2))
           return false;
       if (asstCdcDate3 == null) {
           if (other.asstCdcDate3 != null)
               return false;
       } else if (!asstCdcDate3.equals(other.asstCdcDate3))
           return false;
       if (asstCdcNo1 == null) {
           if (other.asstCdcNo1 != null)
               return false;
       } else if (!asstCdcNo1.equals(other.asstCdcNo1))
           return false;
       if (asstCdcNo2 == null) {
           if (other.asstCdcNo2 != null)
               return false;
       } else if (!asstCdcNo2.equals(other.asstCdcNo2))
           return false;
       if (asstCdcNo3 == null) {
           if (other.asstCdcNo3 != null)
               return false;
       } else if (!asstCdcNo3.equals(other.asstCdcNo3))
           return false;
       if (asstTp == null) {
           if (other.asstTp != null)
               return false;
       } else if (!asstTp.equals(other.asstTp))
           return false;
       if (authMk == null) {
           if (other.authMk != null)
               return false;
       } else if (!authMk.equals(other.authMk))
           return false;
       if (baTaxKey == null) {
           if (other.baTaxKey != null)
               return false;
       } else if (!baTaxKey.equals(other.baTaxKey))
           return false;
       if (baTaxMk == null) {
           if (other.baTaxMk != null)
               return false;
       } else if (!baTaxMk.equals(other.baTaxMk))
           return false;
       if (ban == null) {
           if (other.ban != null)
               return false;
       } else if (!ban.equals(other.ban))
           return false;
       if (behAmt == null) {
           if (other.behAmt != null)
               return false;
       } else if (!behAmt.equals(other.behAmt))
           return false;
       if (bhvAmt == null) {
           if (other.bhvAmt != null)
               return false;
       } else if (!bhvAmt.equals(other.bhvAmt))
           return false;
       if (bhvAmt1 == null) {
           if (other.bhvAmt1 != null)
               return false;
       } else if (!bhvAmt1.equals(other.bhvAmt1))
           return false;
       if (bhvAmt2 == null) {
           if (other.bhvAmt2 != null)
               return false;
       } else if (!bhvAmt2.equals(other.bhvAmt2))
           return false;
       if (bhvAmt3 == null) {
           if (other.bhvAmt3 != null)
               return false;
       } else if (!bhvAmt3.equals(other.bhvAmt3))
           return false;
       if (bhvAmt4 == null) {
           if (other.bhvAmt4 != null)
               return false;
       } else if (!bhvAmt4.equals(other.bhvAmt4))
           return false;
       if (bhvArtc1 == null) {
           if (other.bhvArtc1 != null)
               return false;
       } else if (!bhvArtc1.equals(other.bhvArtc1))
           return false;
       if (bhvArtc2 == null) {
           if (other.bhvArtc2 != null)
               return false;
       } else if (!bhvArtc2.equals(other.bhvArtc2))
           return false;
       if (bhvArtc3 == null) {
           if (other.bhvArtc3 != null)
               return false;
       } else if (!bhvArtc3.equals(other.bhvArtc3))
           return false;
       if (bhvArtc4 == null) {
           if (other.bhvArtc4 != null)
               return false;
       } else if (!bhvArtc4.equals(other.bhvArtc4))
           return false;
       if (billUnit == null) {
           if (other.billUnit != null)
               return false;
       } else if (!billUnit.equals(other.billUnit))
           return false;
       if (carryDate == null) {
           if (other.carryDate != null)
               return false;
       } else if (!carryDate.equals(other.carryDate))
           return false;
       if (carrySeqNo == null) {
           if (other.carrySeqNo != null)
               return false;
       } else if (!carrySeqNo.equals(other.carrySeqNo))
           return false;
       if (caseTp == null) {
           if (other.caseTp != null)
               return false;
       } else if (!caseTp.equals(other.caseTp))
           return false;
       if (chkUnit == null) {
           if (other.chkUnit != null)
               return false;
       } else if (!chkUnit.equals(other.chkUnit))
           return false;
       if (collUnit == null) {
           if (other.collUnit != null)
               return false;
       } else if (!collUnit.equals(other.collUnit))
           return false;
       if (cpt == null) {
           if (other.cpt != null)
               return false;
       } else if (!cpt.equals(other.cpt))
           return false;
       if (cptCdcChar == null) {
           if (other.cptCdcChar != null)
               return false;
       } else if (!cptCdcChar.equals(other.cptCdcChar))
           return false;
       if (cptCdcDate == null) {
           if (other.cptCdcDate != null)
               return false;
       } else if (!cptCdcDate.equals(other.cptCdcDate))
           return false;
       if (cptCdcNo == null) {
           if (other.cptCdcNo != null)
               return false;
       } else if (!cptCdcNo.equals(other.cptCdcNo))
           return false;
       if (createDate == null) {
           if (other.createDate != null)
               return false;
       } else if (!createDate.equals(other.createDate))
           return false;
       if (crmlArtc == null) {
           if (other.crmlArtc != null)
               return false;
       } else if (!crmlArtc.equals(other.crmlArtc))
           return false;
       if (crmlProcDate == null) {
           if (other.crmlProcDate != null)
               return false;
       } else if (!crmlProcDate.equals(other.crmlProcDate))
           return false;
       if (crmlStus == null) {
           if (other.crmlStus != null)
               return false;
       } else if (!crmlStus.equals(other.crmlStus))
           return false;
       if (evadeIncm == null) {
           if (other.evadeIncm != null)
               return false;
       } else if (!evadeIncm.equals(other.evadeIncm))
           return false;
       if (evadeTax == null) {
           if (other.evadeTax != null)
               return false;
       } else if (!evadeTax.equals(other.evadeTax))
           return false;
       if (evdAmt1 == null) {
           if (other.evdAmt1 != null)
               return false;
       } else if (!evdAmt1.equals(other.evdAmt1))
           return false;
       if (evdAmt2 == null) {
           if (other.evdAmt2 != null)
               return false;
       } else if (!evdAmt2.equals(other.evdAmt2))
           return false;
       if (evdAmt3 == null) {
           if (other.evdAmt3 != null)
               return false;
       } else if (!evdAmt3.equals(other.evdAmt3))
           return false;
       if (evdAmt4 == null) {
           if (other.evdAmt4 != null)
               return false;
       } else if (!evdAmt4.equals(other.evdAmt4))
           return false;
       if (evdArtc1 == null) {
           if (other.evdArtc1 != null)
               return false;
       } else if (!evdArtc1.equals(other.evdArtc1))
           return false;
       if (evdArtc2 == null) {
           if (other.evdArtc2 != null)
               return false;
       } else if (!evdArtc2.equals(other.evdArtc2))
           return false;
       if (evdArtc3 == null) {
           if (other.evdArtc3 != null)
               return false;
       } else if (!evdArtc3.equals(other.evdArtc3))
           return false;
       if (evdArtc4 == null) {
           if (other.evdArtc4 != null)
               return false;
       } else if (!evdArtc4.equals(other.evdArtc4))
           return false;
       if (extdReas == null) {
           if (other.extdReas != null)
               return false;
       } else if (!extdReas.equals(other.extdReas))
           return false;
       if (extdTms == null) {
           if (other.extdTms != null)
               return false;
       } else if (!extdTms.equals(other.extdTms))
           return false;
       if (fCnvtMk == null) {
           if (other.fCnvtMk != null)
               return false;
       } else if (!fCnvtMk.equals(other.fCnvtMk))
           return false;
       if (fineAmtTot == null) {
           if (other.fineAmtTot != null)
               return false;
       } else if (!fineAmtTot.equals(other.fineAmtTot))
           return false;
       if (fshAplTp == null) {
           if (other.fshAplTp != null)
               return false;
       } else if (!fshAplTp.equals(other.fshAplTp))
           return false;
       if (fshDate == null) {
           if (other.fshDate != null)
               return false;
       } else if (!fshDate.equals(other.fshDate))
           return false;
       if (id == null) {
           if (other.id != null)
               return false;
       } else if (!id.equals(other.id))
           return false;
       if (invs1 == null) {
           if (other.invs1 != null)
               return false;
       } else if (!invs1.equals(other.invs1))
           return false;
       if (invs2 == null) {
           if (other.invs2 != null)
               return false;
       } else if (!invs2.equals(other.invs2))
           return false;
       if (invsRatio1 == null) {
           if (other.invsRatio1 != null)
               return false;
       } else if (!invsRatio1.equals(other.invsRatio1))
           return false;
       if (invsRatio2 == null) {
           if (other.invsRatio2 != null)
               return false;
       } else if (!invsRatio2.equals(other.invsRatio2))
           return false;
       if (madtrCd == null) {
           if (other.madtrCd != null)
               return false;
       } else if (!madtrCd.equals(other.madtrCd))
           return false;
       if (manageCd == null) {
           if (other.manageCd != null)
               return false;
       } else if (!manageCd.equals(other.manageCd))
           return false;
       if (npnshCd == null) {
           if (other.npnshCd != null)
               return false;
       } else if (!npnshCd.equals(other.npnshCd))
           return false;
       if (npnshReas == null) {
           if (other.npnshReas != null)
               return false;
       } else if (!npnshReas.equals(other.npnshReas))
           return false;
       if (oAdtrCd == null) {
           if (other.oAdtrCd != null)
               return false;
       } else if (!oAdtrCd.equals(other.oAdtrCd))
           return false;
       if (oAsgDate == null) {
           if (other.oAsgDate != null)
               return false;
       } else if (!oAsgDate.equals(other.oAsgDate))
           return false;
       if (oShFshDate == null) {
           if (other.oShFshDate != null)
               return false;
       } else if (!oShFshDate.equals(other.oShFshDate))
           return false;
       if (ovpnshMk == null) {
           if (other.ovpnshMk != null)
               return false;
       } else if (!ovpnshMk.equals(other.ovpnshMk))
           return false;
       if (pnshPrMk == null) {
           if (other.pnshPrMk != null)
               return false;
       } else if (!pnshPrMk.equals(other.pnshPrMk))
           return false;
       if (pnshTp == null) {
           if (other.pnshTp != null)
               return false;
       } else if (!pnshTp.equals(other.pnshTp))
           return false;
       if (prstAdtrCd == null) {
           if (other.prstAdtrCd != null)
               return false;
       } else if (!prstAdtrCd.equals(other.prstAdtrCd))
           return false;
       if (prstAsgDate == null) {
           if (other.prstAsgDate != null)
               return false;
       } else if (!prstAsgDate.equals(other.prstAsgDate))
           return false;
       if (prstPrcdDate == null) {
           if (other.prstPrcdDate != null)
               return false;
       } else if (!prstPrcdDate.equals(other.prstPrcdDate))
           return false;
       if (prstPrcdStus == null) {
           if (other.prstPrcdStus != null)
               return false;
       } else if (!prstPrcdStus.equals(other.prstPrcdStus))
           return false;
       if (prstShFshDate == null) {
           if (other.prstShFshDate != null)
               return false;
       } else if (!prstShFshDate.equals(other.prstShFshDate))
           return false;
       if (reChkUnit == null) {
           if (other.reChkUnit != null)
               return false;
       } else if (!reChkUnit.equals(other.reChkUnit))
           return false;
       if (respIdn == null) {
           if (other.respIdn != null)
               return false;
       } else if (!respIdn.equals(other.respIdn))
           return false;
       if (respNm == null) {
           if (other.respNm != null)
               return false;
       } else if (!respNm.equals(other.respNm))
           return false;
       if (revoCd == null) {
           if (other.revoCd != null)
               return false;
       } else if (!revoCd.equals(other.revoCd))
           return false;
       if (seizeDate == null) {
           if (other.seizeDate != null)
               return false;
       } else if (!seizeDate.equals(other.seizeDate))
           return false;
       if (servArea == null) {
           if (other.servArea != null)
               return false;
       } else if (!servArea.equals(other.servArea))
           return false;
       if (subtaxCd == null) {
           if (other.subtaxCd != null)
               return false;
       } else if (!subtaxCd.equals(other.subtaxCd))
           return false;
       if (timeStamp == null) {
           if (other.timeStamp != null)
               return false;
       } else if (!timeStamp.equals(other.timeStamp))
           return false;
       if (townCd == null) {
           if (other.townCd != null)
               return false;
       } else if (!townCd.equals(other.townCd))
           return false;
       if (trstrCd == null) {
           if (other.trstrCd != null)
               return false;
       } else if (!trstrCd.equals(other.trstrCd))
           return false;
       if (updJdgfDate == null) {
           if (other.updJdgfDate != null)
               return false;
       } else if (!updJdgfDate.equals(other.updJdgfDate))
           return false;
       if (updJdgfStus == null) {
           if (other.updJdgfStus != null)
               return false;
       } else if (!updJdgfStus.equals(other.updJdgfStus))
           return false;
       if (updateDate == null) {
           if (other.updateDate != null)
               return false;
       } else if (!updateDate.equals(other.updateDate))
           return false;
       if (updateUserCd == null) {
           if (other.updateUserCd != null)
               return false;
       } else if (!updateUserCd.equals(other.updateUserCd))
           return false;
       if (urgtLmtDate == null) {
           if (other.urgtLmtDate != null)
               return false;
       } else if (!urgtLmtDate.equals(other.urgtLmtDate))
           return false;
       if (vioBDate == null) {
           if (other.vioBDate != null)
               return false;
       } else if (!vioBDate.equals(other.vioBDate))
           return false;
       if (vioEDate == null) {
           if (other.vioEDate != null)
               return false;
       } else if (!vioEDate.equals(other.vioEDate))
           return false;
       if (vioFactCd1 == null) {
           if (other.vioFactCd1 != null)
               return false;
       } else if (!vioFactCd1.equals(other.vioFactCd1))
           return false;
       if (vioFactCd2 == null) {
           if (other.vioFactCd2 != null)
               return false;
       } else if (!vioFactCd2.equals(other.vioFactCd2))
           return false;
       if (vioHostIdnBan == null) {
           if (other.vioHostIdnBan != null)
               return false;
       } else if (!vioHostIdnBan.equals(other.vioHostIdnBan))
           return false;
       if (vioHostNm == null) {
           if (other.vioHostNm != null)
               return false;
       } else if (!vioHostNm.equals(other.vioHostNm))
           return false;
       if (vioYr == null) {
           if (other.vioYr != null)
               return false;
       } else if (!vioYr.equals(other.vioYr))
           return false;
       if (ynArrgMtg == null) {
           if (other.ynArrgMtg != null)
               return false;
       } else if (!ynArrgMtg.equals(other.ynArrgMtg))
           return false;
       if (zipCd == null) {
           if (other.zipCd != null)
               return false;
       } else if (!zipCd.equals(other.zipCd))
           return false;
       return true;
   }


Solution
透過Apache Commons Lang的HashCodeBuilder與EqualsBuilder來解決此問題。


Steps
1. 建立一個Domain Base Class,裡頭透過Commons Lang的API來進行實作hashCode與equals method
實作內容很簡單,如下:

 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
   package gov.fdc.nig.domain;
   
   import org.apache.commons.lang.builder.CompareToBuilder;
   import org.apache.commons.lang.builder.EqualsBuilder;
   import org.apache.commons.lang.builder.HashCodeBuilder;
   import org.apache.commons.lang.builder.ToStringBuilder;
   
   public class DomainBase {
   
       /*
        * This class enables a good hashCode method to be built for any class.
        * It follows the rules laid out in the book Effective Java by Joshua Bloch.
        * Writing a good hashCode method is actually quite difficult.
        * This class aims to simplify the process.
        * (non-Javadoc)
        * @see java.lang.Object#hashCode()
        */
       public int hashCode() {
           return HashCodeBuilder.reflectionHashCode(this);
       }
   
       /*
        * This class provides methods to build a good equals method for any class.
        * It follows rules laid out in Effective Java , by Joshua Bloch.
        * In particular the rule for comparing doubles, floats, and arrays can be tricky.
        * Also, making sure that equals() and hashCode() are consistent can be difficult.
        * (non-Javadoc)
        * @see java.lang.Object#equals(java.lang.Object)
        */
       public boolean equals(Object obj) {
           return EqualsBuilder.reflectionEquals(this, obj);
       }
   
       /*
        * Assists in implementing Comparable.compareTo(Object) methods.
        * It is consistent with equals(Object) and hashcode() built with EqualsBuilder and HashCodeBuilder.
        */
       public int compareTo(Object obj) {
           return CompareToBuilder.reflectionCompare(this, obj);
       }
   
       /*
        * Assists in implementing Object.toString() methods.
        *
        * (non-Javadoc)
        * @see java.lang.Object#toString()
        */
       public String toString() {
           return ToStringBuilder.reflectionToString(this);
       }
   
   }



2. 原本的entity class,先繼承DomainBase,再來刪除不必要的equals, hashCode與toString method,通通交給DomainBase處理即可。class之間的關係如下:


  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
   package gov.fdc.nig.domain;
   
   import java.sql.Timestamp;
   
   import javax.persistence.Column;
   import javax.persistence.Entity;
   import javax.persistence.Id;
   import javax.persistence.Table;
   
   /**
    * Nigt036 entity. @author MyEclipse Persistence Tools
    */
   @Entity
   @Table(name = "NIGT036", schema = "AP_TAX")
   public class Nigt036 extends DomainBase implements java.io.Serializable {
   
       /**
        *
        */
       private static final long serialVersionUID = 627363036088777178 L;
       // Fields
       private String vioOrgCd;
       private String vioOrgNm;
       private String vioOrgShnm;
       private String bureauCd;
       private Timestamp timeStamp;
       private String updateCd;
       private String userId;
       private String updateDate;
   
       // Constructors
   
       /** default constructor */
       public Nigt036() {}
   
       /** minimal constructor */
       public Nigt036(String vioOrgCd) {
           this.vioOrgCd = vioOrgCd;
       }
   
       /** full constructor */
       public Nigt036(String vioOrgCd, String bureauCd, Timestamp timeStamp,
           String updateCd, String updateDate, String userId, String vioOrgNm,
           String vioOrgShnm) {
           super();
           this.vioOrgCd = vioOrgCd;
           this.bureauCd = bureauCd;
           this.timeStamp = timeStamp;
           this.updateCd = updateCd;
           this.updateDate = updateDate;
           this.userId = userId;
           this.vioOrgNm = vioOrgNm;
           this.vioOrgShnm = vioOrgShnm;
       }
   
       // Property accessors
       @Id
       @Column(name = "VIO_ORG_CD", unique = true, nullable = false, length = 4)
       public String getVioOrgCd() {
           return this.vioOrgCd;
       }
   
       public void setVioOrgCd(String vioOrgCd) {
           this.vioOrgCd = vioOrgCd;
       }
   
       @Column(name = "VIO_ORG_NM")
       public String getVioOrgNm() {
           return this.vioOrgNm;
       }
   
       public void setVioOrgNm(String vioOrgNm) {
           this.vioOrgNm = vioOrgNm;
       }
   
       @Column(name = "VIO_ORG_SHNM")
       public String getVioOrgShnm() {
           return this.vioOrgShnm;
       }
   
       public void setVioOrgShnm(String vioOrgShnm) {
           this.vioOrgShnm = vioOrgShnm;
       }
   
       @Column(name = "BUREAU_CD", length = 3)
       public String getBureauCd() {
           return this.bureauCd;
       }
   
       public void setBureauCd(String bureauCd) {
           this.bureauCd = bureauCd;
       }
   
       @Column(name = "TIME_STAMP", length = 11)
       public Timestamp getTimeStamp() {
           return this.timeStamp;
       }
   
       public void setTimeStamp(Timestamp timeStamp) {
           this.timeStamp = timeStamp;
       }
   
       @Column(name = "UPDATE_CD", length = 2)
       public String getUpdateCd() {
           return this.updateCd;
       }
   
       public void setUpdateCd(String updateCd) {
           this.updateCd = updateCd;
       }
   
       @Column(name = "USER_ID", length = 8)
       public String getUserId() {
           return this.userId;
       }
   
       public void setUserId(String userId) {
           this.userId = userId;
       }
   
       @Column(name = "UPDATE_DATE", length = 7)
       public String getUpdateDate() {
           return this.updateDate;
       }
   
       public void setUpdateDate(String updateDate) {
           this.updateDate = updateDate;
       }
   }

Benefits
1. 測試起來較輕鬆,且能有效提昇code coverage
2. 讓程式更加精簡、好維護
3. follow rules laid out in Effective Java , by Joshua Bloch


2011/06/04

JasperSoft Integrates iReport Into Eclipse Development Platform

Intall JasperSoft into Eclipse

1. Open Eclipse --> Help --> Eclipse Marketplace

2. Choose "Eclipse Marketplace" --> Next

3. Use "ireport" as keyword and click "Go"-->Click "Install"

4. Please be patient.

5. Click "Next"

6. Choose "I Accept...", Click "Finish"

7. Installing Software...

8. Click "Restart Now" to restart Eclipse

Open Eclipse Again
1. Open jrxml file

2. See. You can edit jrxml in eclipse, do not need to open iReport again.

how to Set JavaBean DataSource in iReport

Setup Classpath

1. iReport --> Preferences

2. Click Classpath tab --> Click "Add Folder"

3. Choose class folder --> Click "Choose"

4. Check "Reloadable" checkbox --> Click OK

Create a new report template
1. File --> New


2. Choose "Blank A4" --> Click "Open This Template"

3. Assign report name and location, Click "Next"


4. Click Finish

5. Right Click -->Edit Query

6. Choose "JavaBean DataSource"-->Assign "class name"-->Click Read Attriutes

7. Choose "selected attributes" --> Click "add selected attributes"

8. Click OK

9. Unfold "Fields", then you can see the attributes we added before will show under Fields

10. Drag "Department" field into template. Then DONE.


2011/06/02

利用enumeration type來做下拉選單

我們在開發的時候,會遇到某些下拉選單不是從資料庫抓出來的,寫死在jsp好像不太恰當,寫在property file再抓出來又有點麻煩,如下圖所示,輸出格式、法務科別、下授類別等,下拉單內容很固定、又不需要放在資料庫:


這邊我建議用Java的enumeration type來建立下拉選單。步驟如下(以法務科別為例):

1. 建立enumeration class (若下選選單有增減,只要修改enumeration即可)
 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
   package gov.fdc.nig.enumeration;
   
   /**
    * 法務科別 enumeration
    *
    * @author albert
    *
    */
   public enum LegalSectionEnum {
   
       SECTION1("1.法務一科", "1"), SECTION2("2.法務二科", "2"), ALL("3.全部", "3");
   
       private final String label;
       private final String value;
   
       public String getLabel() {
           return label;
       }
   
       public String getValue() {
           return value;
       }
   
       private LegalSectionEnum(String label, String value) {
           this.label = label;
           this.value = value;
       }
   
       public static void main(String args[]) {
           LegalSectionEnum[] enumArr = LegalSectionEnum.values();
           for (LegalSectionEnum enumeration: enumArr) {
               System.out.println("label=" + enumeration.getLabel() + ", value=" +
                   enumeration.getValue());
           }
       }
   }

2. 在NIGUtilsConroller增加一個method來抓取enumeration中所定義的values
 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
   /**
    * 取得法務科別下拉單
    * 
    * @param res loadDelegationUnitList
    * @param session HttpSession
    * @throws IOException if exception happens
    */
   @RequestMapping(value = "/loadLegalSectionList", method = RequestMethod.POST)
   public @ResponseBody
   void loadLegalSectionList(final HttpServletResponse res, final HttpSession session)
   throws IOException {
       final JSONArray jsonArray = new JSONArray();
   
       try {
           final LegalSectionEnum[] enumArr = LegalSectionEnum.values();
   
           for (LegalSectionEnum enumeration: enumArr) {
               Map map = new HashMap();
               map.put("value", enumeration.getValue());
               map.put("name", enumeration.getLabel());
   
               jsonArray.add(map);
           }
       } catch (FDCDataAccessException e) {
           LoggerFactory.getLogger(this.getClass()).debug(
               "loadExportFormatList exception: " + e.getMessage());
       }
   
       res.setContentType(NigAccessKey.JKEY_CONTENT_TYPE);
       res.getWriter().write(jsonArray.toString());
   }


3. 在nig.utils.js增加一個function來取得法務科別下拉單


4. 在功能相對應的js,呼叫nig.utils.js所定義的JavaScript function


JavaScript function所定義的id,與下拉選單的id需要對應

2011/05/31

eclipse-fonts

Easily control Eclipse fonts size. Update site: http://eclipse-fonts.googlecode.com/svn/trunk/FontsUpdate/

Shortcuts -

CTRL+= : Increase fonts

CTRL+- : Decrease fonts

2011/05/28

My Travel Brain

Travel Map
I've been to 38 cities in 11 countries
Asia
China: Shenzhen
Hong Kong (SAR): Hong Kong Island
Japan: Asahikawa
Japan: Fukuoka
Japan: Hakodate
Japan: Hokkaido
Japan: Kyoto
Japan: Nagano
Japan: Nagoya
Japan: Onuma
Japan: Sapporo
Japan: Sendai
Japan: Tokyo
Malaysia: Kuala Lumpur
Singapore: Singapore
South Korea: Seoul
Taiwan: T'ai-nan
Taiwan: T'ai-pei
Taiwan: T'ao-yuan
Taiwan: Yilan City
Europe
France: Arles
France: Avignon
France: Carcassonne
France: Entrevaux
France: Gordes
France: Le Fugeret
France: Nice
France: Nimes
France: Paris
France: Roussillon
France: Saint-Paul
France: Sorgues
Italy: Milano
Monaco: Monte-Carlo
North America
Canada: Toronto

Utilize Commons BeansUtils to do copy object