Skip to content

Commit 1b02b21

Browse files
committed
Size reduction improvements
Signed-off-by: Carlos Quiroz <carlos.m.quiroz@gmail.com>
1 parent dfe7a97 commit 1b02b21

36 files changed

+287
-268
lines changed

core/jvm/src/main/scala/org/threeten/bp/chrono/HijrahDateConfigurator.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ import java.text.ParseException
1414
object HijrahDateConfigurator {
1515

1616
/** File separator. */
17-
private val FILE_SEP: Char = File.separatorChar
17+
private def FILE_SEP: Char = File.separatorChar
1818

1919
/** Path separator. */
20-
private val PATH_SEP: String = File.pathSeparator
20+
private def PATH_SEP: String = File.pathSeparator
2121

2222
/** Default config file name. */
23-
private val DEFAULT_CONFIG_FILENAME: String = "hijrah_deviation.cfg"
23+
private def DEFAULT_CONFIG_FILENAME: String = "hijrah_deviation.cfg"
2424

2525
/** Default path to the config file. */
26-
private val DEFAULT_CONFIG_PATH: String = s"org${FILE_SEP}threeten${FILE_SEP}bp${FILE_SEP}chrono"
26+
private def DEFAULT_CONFIG_PATH: String = s"org${FILE_SEP}threeten${FILE_SEP}bp${FILE_SEP}chrono"
2727

2828
/** Read hijrah_deviation.cfg file. The config file contains the deviation data with
2929
* following format.

core/shared/src/main/scala/org/threeten/bp/DayOfWeek.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ object DayOfWeek {
118118

119119
/** Private cache of all the constants.
120120
*/
121-
private val ENUMS: Array[DayOfWeek] = DayOfWeek.values
121+
private def ENUMS: Array[DayOfWeek] = DayOfWeek.values
122122

123123
/** Obtains an instance of {@code DayOfWeek} from an {@code int} value.
124124
*
@@ -242,7 +242,7 @@ final class DayOfWeek(name: String, ordinal: Int)
242242
if (field eq DAY_OF_WEEK)
243243
field.range
244244
else if (field.isInstanceOf[ChronoField])
245-
throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
245+
throw throw UnsupportedTemporalTypeException.field(field)
246246
else
247247
field.rangeRefinedBy(this)
248248

@@ -299,7 +299,7 @@ final class DayOfWeek(name: String, ordinal: Int)
299299
if (field eq DAY_OF_WEEK)
300300
getValue.toLong
301301
else if (field.isInstanceOf[ChronoField])
302-
throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
302+
throw throw UnsupportedTemporalTypeException.field(field)
303303
else
304304
field.getFrom(this)
305305

core/shared/src/main/scala/org/threeten/bp/Duration.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ object Duration {
6767
val ZERO: Duration = new Duration(0, 0)
6868

6969
/** Constant for nanos per second. */
70-
private val NANOS_PER_SECOND: Int = 1000000000
70+
private def NANOS_PER_SECOND: Int = 1000000000
7171

7272
/** Constant for nanos per milli. */
73-
private val NANOS_PER_MILLI: Int = 1000000
73+
private def NANOS_PER_MILLI: Int = 1000000
7474

7575
/** Constant for nanos per second. */
76-
private val BI_NANOS_PER_SECOND: BigInteger = BigInteger.valueOf(NANOS_PER_SECOND.toLong)
76+
private def BI_NANOS_PER_SECOND: BigInteger = BigInteger.valueOf(NANOS_PER_SECOND.toLong)
7777

7878
/** The pattern for parsing. */
79-
private val PATTERN: Pattern = Pattern.compile(
79+
private def PATTERN: Pattern = Pattern.compile(
8080
"([-+]?)P(?:([-+]?[0-9]+)D)?" + "(T(?:([-+]?[0-9]+)H)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)(?:[.,]([0-9]{0,9}))?S)?)?",
8181
Pattern.CASE_INSENSITIVE
8282
)
@@ -485,7 +485,7 @@ final class Duration private (private val seconds: Long, private val nanos: Int)
485485
def get(unit: TemporalUnit): Long =
486486
if (unit eq SECONDS) seconds
487487
else if (unit eq NANOS) nanos.toLong
488-
else throw new UnsupportedTemporalTypeException(s"Unsupported unit: $unit")
488+
else throw UnsupportedTemporalTypeException.unit(unit)
489489

490490
/** Checks if this duration is zero length.
491491
*

core/shared/src/main/scala/org/threeten/bp/Instant.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ object Instant {
6969
val EPOCH: Instant = new Instant(0, 0)
7070

7171
/** The minimum supported epoch second. */
72-
private val MIN_SECOND: Long = -31557014167219200L
72+
private def MIN_SECOND: Long = -31557014167219200L
7373

7474
/** The maximum supported epoch second. */
75-
private val MAX_SECOND: Long = 31556889864403199L
75+
private def MAX_SECOND: Long = 31556889864403199L
7676

7777
/** Constant for nanos per second. */
78-
private val NANOS_PER_SECOND: Int = 1000000000
78+
private def NANOS_PER_SECOND: Int = 1000000000
7979

8080
/** Constant for nanos per milli. */
81-
private val NANOS_PER_MILLI: Int = 1000000
81+
private def NANOS_PER_MILLI: Int = 1000000
8282

8383
/** Constant for millis per sec. */
84-
private val MILLIS_PER_SEC = 1000
84+
private def MILLIS_PER_SEC = 1000
8585

8686
/** The minimum supported {@code Instant}, '-1000000000-01-01T00:00Z'.
8787
* This could be used by an application as a "far past" instant.
@@ -437,7 +437,7 @@ final class Instant private (private val seconds: Long, private val nanos: Int)
437437
case NANO_OF_SECOND => nanos
438438
case MICRO_OF_SECOND => nanos / 1000
439439
case MILLI_OF_SECOND => nanos / Instant.NANOS_PER_MILLI
440-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
440+
case _ => throw UnsupportedTemporalTypeException.field(field)
441441
}
442442
case _ => range(field).checkValidIntValue(field.getFrom(this), field)
443443
}
@@ -471,7 +471,7 @@ final class Instant private (private val seconds: Long, private val nanos: Int)
471471
case MICRO_OF_SECOND => nanos / 1000L
472472
case MILLI_OF_SECOND => nanos.toLong / Instant.NANOS_PER_MILLI
473473
case INSTANT_SECONDS => seconds
474-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
474+
case _ => throw UnsupportedTemporalTypeException.field(field)
475475
}
476476
case _ => field.getFrom(this)
477477
}
@@ -574,7 +574,7 @@ final class Instant private (private val seconds: Long, private val nanos: Int)
574574
case INSTANT_SECONDS =>
575575
return if (newValue != seconds) Instant.create(newValue, nanos) else this
576576
case _ =>
577-
throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
577+
throw UnsupportedTemporalTypeException.field(field)
578578
}
579579
case _ =>
580580
}
@@ -651,7 +651,7 @@ final class Instant private (private val seconds: Long, private val nanos: Int)
651651
case DAYS =>
652652
return plusSeconds(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY.toLong))
653653
case _ =>
654-
throw new UnsupportedTemporalTypeException(s"Unsupported unit: $unit")
654+
throw UnsupportedTemporalTypeException.unit(unit)
655655
}
656656
case _ =>
657657
}
@@ -890,7 +890,7 @@ final class Instant private (private val seconds: Long, private val nanos: Int)
890890
case DAYS =>
891891
return secondsUntil(end) / SECONDS_PER_DAY
892892
case _ =>
893-
throw new UnsupportedTemporalTypeException(s"Unsupported unit: $unit")
893+
throw throw UnsupportedTemporalTypeException.unit(unit)
894894
}
895895
case _ =>
896896
}

core/shared/src/main/scala/org/threeten/bp/LocalDate.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ object LocalDate {
8585
val MAX: LocalDate = LocalDate.of(Year.MAX_VALUE, 12, 31)
8686

8787
/** The number of days in a 400 year cycle. */
88-
private val DAYS_PER_CYCLE: Int = 146097
88+
private def DAYS_PER_CYCLE: Int = 146097
8989

9090
/** The number of days from year zero to year 1970.
9191
* There are five 400 year cycles from year zero to 2000.
9292
* There are 7 leap years from 1970 to 2000.
9393
*/
94-
private[bp] val DAYS_0000_TO_1970: Long = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L)
94+
private[bp] def DAYS_0000_TO_1970: Long = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L)
9595

9696
/** Obtains the current date from the system clock in the default time-zone.
9797
*
@@ -439,7 +439,7 @@ final class LocalDate private (private val year: Int, monthOfYear: Int, dayOfMon
439439
case _ => field.range
440440
}
441441
} else {
442-
throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
442+
throw UnsupportedTemporalTypeException.field(field)
443443
}
444444
} else {
445445
field.rangeRefinedBy(this)
@@ -519,7 +519,7 @@ final class LocalDate private (private val year: Int, monthOfYear: Int, dayOfMon
519519
case YEAR_OF_ERA => if (year >= 1) year.toLong else 1 - year.toLong
520520
case YEAR => year.toLong
521521
case ERA => if (year >= 1) 1 else 0
522-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
522+
case _ => throw UnsupportedTemporalTypeException.field(field)
523523
}
524524

525525
private def getProlepticMonth: Long = (year * 12L) + (month - 1)
@@ -934,7 +934,7 @@ final class LocalDate private (private val year: Int, monthOfYear: Int, dayOfMon
934934
case CENTURIES => plusYears(Math.multiplyExact(amountToAdd, 100))
935935
case MILLENNIA => plusYears(Math.multiplyExact(amountToAdd, 1000))
936936
case ERAS => `with`(ERA, Math.addExact(getLong(ERA), amountToAdd))
937-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported unit: $unit")
937+
case _ => throw throw UnsupportedTemporalTypeException.unit(unit)
938938
}
939939
} else {
940940
unit.addTo(this, amountToAdd)
@@ -1254,7 +1254,7 @@ final class LocalDate private (private val year: Int, monthOfYear: Int, dayOfMon
12541254
case CENTURIES => monthsUntil(end) / 1200
12551255
case MILLENNIA => monthsUntil(end) / 12000
12561256
case ERAS => end.getLong(ERA) - getLong(ERA)
1257-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported unit: $unit")
1257+
case _ => throw throw UnsupportedTemporalTypeException.unit(unit)
12581258
}
12591259

12601260
} else {

core/shared/src/main/scala/org/threeten/bp/LocalDateTime.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ final class LocalDateTime private (private val date: LocalDate, private val time
14041404
case HALF_DAYS =>
14051405
return Math.addExact(Math.multiplyExact(daysUntil, 2),
14061406
timeUntil / (NANOS_PER_HOUR * 12))
1407-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported unit: $unit")
1407+
case _ => throw UnsupportedTemporalTypeException.unit(unit)
14081408

14091409
}
14101410
}

core/shared/src/main/scala/org/threeten/bp/LocalTime.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,40 +91,40 @@ object LocalTime {
9191
val NOON: LocalTime = HOURS(12)
9292

9393
/** Hours per day. */
94-
private[bp] val HOURS_PER_DAY: Int = 24
94+
private[bp] def HOURS_PER_DAY: Int = 24
9595

9696
/** Minutes per hour. */
97-
private[bp] val MINUTES_PER_HOUR: Int = 60
97+
private[bp] def MINUTES_PER_HOUR: Int = 60
9898

9999
/** Minutes per day. */
100-
private[bp] val MINUTES_PER_DAY: Int = MINUTES_PER_HOUR * HOURS_PER_DAY
100+
private[bp] def MINUTES_PER_DAY: Int = MINUTES_PER_HOUR * HOURS_PER_DAY
101101

102102
/** Seconds per minute. */
103-
private[bp] val SECONDS_PER_MINUTE: Int = 60
103+
private[bp] def SECONDS_PER_MINUTE: Int = 60
104104

105105
/** Seconds per hour. */
106-
private[bp] val SECONDS_PER_HOUR: Int = SECONDS_PER_MINUTE * MINUTES_PER_HOUR
106+
private[bp] def SECONDS_PER_HOUR: Int = SECONDS_PER_MINUTE * MINUTES_PER_HOUR
107107

108108
/** Seconds per day. */
109-
private[bp] val SECONDS_PER_DAY: Int = SECONDS_PER_HOUR * HOURS_PER_DAY
109+
private[bp] def SECONDS_PER_DAY: Int = SECONDS_PER_HOUR * HOURS_PER_DAY
110110

111111
/** Milliseconds per day. */
112-
private[bp] val MILLIS_PER_DAY: Long = SECONDS_PER_DAY * 1000L
112+
private[bp] def MILLIS_PER_DAY: Long = SECONDS_PER_DAY * 1000L
113113

114114
/** Microseconds per day. */
115-
private[bp] val MICROS_PER_DAY: Long = SECONDS_PER_DAY * 1000000L
115+
private[bp] def MICROS_PER_DAY: Long = SECONDS_PER_DAY * 1000000L
116116

117117
/** Nanos per second. */
118-
private[bp] val NANOS_PER_SECOND: Long = 1000000000L
118+
private[bp] def NANOS_PER_SECOND: Long = 1000000000L
119119

120120
/** Nanos per minute. */
121-
private[bp] val NANOS_PER_MINUTE: Long = NANOS_PER_SECOND * SECONDS_PER_MINUTE
121+
private[bp] def NANOS_PER_MINUTE: Long = NANOS_PER_SECOND * SECONDS_PER_MINUTE
122122

123123
/** Nanos per hour. */
124-
private[bp] val NANOS_PER_HOUR: Long = NANOS_PER_MINUTE * MINUTES_PER_HOUR
124+
private[bp] def NANOS_PER_HOUR: Long = NANOS_PER_MINUTE * MINUTES_PER_HOUR
125125

126126
/** Nanos per day. */
127-
private[bp] val NANOS_PER_DAY: Long = NANOS_PER_HOUR * HOURS_PER_DAY
127+
private[bp] def NANOS_PER_DAY: Long = NANOS_PER_HOUR * HOURS_PER_DAY
128128

129129
/** Obtains the current time from the system clock in the default time-zone.
130130
*

core/shared/src/main/scala/org/threeten/bp/Month.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object Month {
151151

152152
/** Private cache of all the constants.
153153
*/
154-
private val ENUMS: Array[Month] = Month.values
154+
private def ENUMS: Array[Month] = Month.values
155155

156156
/** Obtains an instance of {@code Month} from an {@code int} value.
157157
*
@@ -282,7 +282,7 @@ final class Month private (name: String, ordinal: Int)
282282
if (field eq MONTH_OF_YEAR)
283283
field.range
284284
else if (field.isInstanceOf[ChronoField])
285-
throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
285+
throw UnsupportedTemporalTypeException.field(field)
286286
else
287287
field.rangeRefinedBy(this)
288288

@@ -339,7 +339,7 @@ final class Month private (name: String, ordinal: Int)
339339
if (field eq MONTH_OF_YEAR)
340340
getValue.toLong
341341
else if (field.isInstanceOf[ChronoField])
342-
throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
342+
throw throw UnsupportedTemporalTypeException.field(field)
343343
else
344344
field.getFrom(this)
345345

core/shared/src/main/scala/org/threeten/bp/MonthDay.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ import org.threeten.bp.temporal.ValueRange
5959
object MonthDay {
6060

6161
/** Parser. */
62-
private val PARSER: DateTimeFormatter = new DateTimeFormatterBuilder()
63-
.appendLiteral("--")
64-
.appendValue(MONTH_OF_YEAR, 2)
65-
.appendLiteral('-')
66-
.appendValue(DAY_OF_MONTH, 2)
67-
.toFormatter
62+
private def PARSER: DateTimeFormatter =
63+
new DateTimeFormatterBuilder()
64+
.appendLiteral("--")
65+
.appendValue(MONTH_OF_YEAR, 2)
66+
.appendLiteral('-')
67+
.appendValue(DAY_OF_MONTH, 2)
68+
.toFormatter
6869

6970
/** Obtains the current month-day from the system clock in the default time-zone.
7071
*
@@ -317,7 +318,7 @@ final class MonthDay private (private val month: Int, private val day: Int)
317318
ValueRange.of(1, getMonth.minLength.toLong, getMonth.maxLength.toLong)
318319
else if (field.isInstanceOf[ChronoField])
319320
if (isSupported(field)) field.range
320-
else throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
321+
else throw UnsupportedTemporalTypeException.field(field)
321322
else
322323
field.rangeRefinedBy(this)
323324

@@ -373,7 +374,7 @@ final class MonthDay private (private val month: Int, private val day: Int)
373374
field1 match {
374375
case DAY_OF_MONTH => day.toLong
375376
case MONTH_OF_YEAR => month.toLong
376-
case _ => throw new UnsupportedTemporalTypeException(s"Unsupported field: $field")
377+
case _ => throw UnsupportedTemporalTypeException.field(field)
377378
}
378379
case _ => field.getFrom(this)
379380
}

core/shared/src/main/scala/org/threeten/bp/OffsetDateTime.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ object OffsetDateTime {
9191
*/
9292
def timeLineOrder: Comparator[OffsetDateTime] = INSTANT_COMPARATOR
9393

94-
private val INSTANT_COMPARATOR: Comparator[OffsetDateTime] =
94+
private def INSTANT_COMPARATOR: Comparator[OffsetDateTime] =
9595
new Comparator[OffsetDateTime] {
9696
override def compare(datetime1: OffsetDateTime, datetime2: OffsetDateTime): Int = {
9797
var cmp: Int = java.lang.Long.compare(datetime1.toEpochSecond, datetime2.toEpochSecond)

0 commit comments

Comments
 (0)