Closed LVMVRQUXL closed 5 months ago
In the future, we could make instances of this type comparable with themselves and the integer types from the Kotlin standard library.
interface PositiveInt : Comparable<PositiveInteger> {
operator fun compareTo(other: Byte): Int
operator fun compareTo(other: Short): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: PositiveInteger): Int
}
In the future, we could add support for basic arithmetic operations +
, -
, *
, /
and %
.
In the future, we could provide additional conversions for the PositiveInt
.
interface PositiveInt {
fun toByte(): Byte
fun toShort(): Short
fun toLong(): Long
fun toFloat(): Float
fun toDouble(): Double
}
In the future, we could introduce types representing the digits 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
and 9
. The digit 0
is already represented by the Zero
experimental type in the org.kotools.types
package.
It may also be interesting to move types related to digits in a new org.kotools.types.digit
package.
This type will be implemented internally for the PositiveInteger
type (see issue #661).
📝 Description
We want to introduce a
PositiveInt
experimental type, in theorg.kotools.types
package of thetypes
Gradle subproject, for representing an integer of typeInt
that is greater than zero. This type should be serializable asInt
.Here's the Application Programming Interface (API) goal for this type:
🔗 Dependencies
This issue is blocked by the following ones:
✅ Checklist
fromIntOrNull(Int)
function with tests, documentation and samples.fromInt(Int)
function with tests, documentation and samples.toInt()
function with tests, documentation and samples.toString()
function with tests, documentation and samples.equals(Any?)
andhashCode()
functions) with tests, documentation and samples.min
property with tests, documentation and samples.max
property with tests, documentation and samples.random()
function with tests, documentation and samples.KotoolsTypesSerializers.positiveInt
property for making this type serializable asInt
.Byte
andShort
types.