@@ -94,8 +94,8 @@ public Builder factor(float factor) {
94
94
return this ;
95
95
}
96
96
97
- public TimeZoneRounding build () {
98
- TimeZoneRounding timeZoneRounding ;
97
+ public Rounding build () {
98
+ Rounding timeZoneRounding ;
99
99
if (unit != null ) {
100
100
if (preTz .equals (DateTimeZone .UTC ) && postTz .equals (DateTimeZone .UTC )) {
101
101
timeZoneRounding = new UTCTimeZoneRoundingFloor (unit );
@@ -114,10 +114,10 @@ public TimeZoneRounding build() {
114
114
}
115
115
}
116
116
if (preOffset != 0 || postOffset != 0 ) {
117
- timeZoneRounding = new PrePostTimeZoneRounding (timeZoneRounding , preOffset , postOffset );
117
+ timeZoneRounding = new PrePostRounding (timeZoneRounding , preOffset , postOffset );
118
118
}
119
119
if (factor != 1.0f ) {
120
- timeZoneRounding = new FactorTimeZoneRounding (timeZoneRounding , factor );
120
+ timeZoneRounding = new FactorRounding (timeZoneRounding , factor );
121
121
}
122
122
return timeZoneRounding ;
123
123
}
@@ -439,106 +439,4 @@ public void writeTo(StreamOutput out) throws IOException {
439
439
out .writeSharedString (postTz .getID ());
440
440
}
441
441
}
442
-
443
- static class FactorTimeZoneRounding extends TimeZoneRounding {
444
-
445
- final static byte ID = 7 ;
446
-
447
- private TimeZoneRounding timeZoneRounding ;
448
-
449
- private float factor ;
450
-
451
- FactorTimeZoneRounding () { // for serialization
452
- }
453
-
454
- FactorTimeZoneRounding (TimeZoneRounding timeZoneRounding , float factor ) {
455
- this .timeZoneRounding = timeZoneRounding ;
456
- this .factor = factor ;
457
- }
458
-
459
- @ Override
460
- public byte id () {
461
- return ID ;
462
- }
463
-
464
- @ Override
465
- public long roundKey (long utcMillis ) {
466
- return timeZoneRounding .roundKey ((long ) (factor * utcMillis ));
467
- }
468
-
469
- @ Override
470
- public long valueForKey (long key ) {
471
- return timeZoneRounding .valueForKey (key );
472
- }
473
-
474
- @ Override
475
- public long nextRoundingValue (long value ) {
476
- return timeZoneRounding .nextRoundingValue (value );
477
- }
478
-
479
- @ Override
480
- public void readFrom (StreamInput in ) throws IOException {
481
- timeZoneRounding = (TimeZoneRounding ) Rounding .Streams .read (in );
482
- factor = in .readFloat ();
483
- }
484
-
485
- @ Override
486
- public void writeTo (StreamOutput out ) throws IOException {
487
- Rounding .Streams .write (timeZoneRounding , out );
488
- out .writeFloat (factor );
489
- }
490
- }
491
-
492
- static class PrePostTimeZoneRounding extends TimeZoneRounding {
493
-
494
- final static byte ID = 8 ;
495
-
496
- private TimeZoneRounding timeZoneRounding ;
497
-
498
- private long preOffset ;
499
- private long postOffset ;
500
-
501
- PrePostTimeZoneRounding () { // for serialization
502
- }
503
-
504
- PrePostTimeZoneRounding (TimeZoneRounding timeZoneRounding , long preOffset , long postOffset ) {
505
- this .timeZoneRounding = timeZoneRounding ;
506
- this .preOffset = preOffset ;
507
- this .postOffset = postOffset ;
508
- }
509
-
510
- @ Override
511
- public byte id () {
512
- return ID ;
513
- }
514
-
515
- @ Override
516
- public long roundKey (long utcMillis ) {
517
- return timeZoneRounding .roundKey (utcMillis + preOffset );
518
- }
519
-
520
- @ Override
521
- public long valueForKey (long key ) {
522
- return postOffset + timeZoneRounding .valueForKey (key );
523
- }
524
-
525
- @ Override
526
- public long nextRoundingValue (long value ) {
527
- return postOffset + timeZoneRounding .nextRoundingValue (value - postOffset );
528
- }
529
-
530
- @ Override
531
- public void readFrom (StreamInput in ) throws IOException {
532
- timeZoneRounding = (TimeZoneRounding ) Rounding .Streams .read (in );
533
- preOffset = in .readVLong ();
534
- postOffset = in .readVLong ();
535
- }
536
-
537
- @ Override
538
- public void writeTo (StreamOutput out ) throws IOException {
539
- Rounding .Streams .write (timeZoneRounding , out );
540
- out .writeVLong (preOffset );
541
- out .writeVLong (postOffset );
542
- }
543
- }
544
442
}
0 commit comments