alternatively, if you really don't want to expose ...
# kotest
s
alternatively, if you really don't want to expose the constructor, go back to a standard class, and implement the equals/hashcode methods yourself
Copy code
class Time private constructor(val hours: Int, val minutes: Int, val seconds: Int) {

   companion object {
      operator fun invoke(hours: Int, minutes: Int, seconds: Int): Time {
         return Time(1, 2, 3) // do your overflow stuff here
      }
   }

   override fun equals(other: Any?): Boolean {
      if (this === other) return true
      if (javaClass != other?.javaClass) return false

      other as Time

      if (hours != other.hours) return false
      if (minutes != other.minutes) return false
      if (seconds != other.seconds) return false

      return true
   }

   override fun hashCode(): Int {
      var result = hours
      result = 31 * result + minutes
      result = 31 * result + seconds
      return result
   }
}