Skip to content

✨ New NegativeInt type in org.kotools.types package #853

@LVMVRQUXL

Description

@LVMVRQUXL

πŸ“ Description

For representing an integer of type Int that is less than zero, we want to add the NegativeInt experimental type, in the org.kotools.types package of the types Gradle subproject.

By default, this type should be serializable as Int.

Here's the minimum viable Application Programming Interface (API) for the NegativeInt type:

// In 'org.kotools.types' package:

class NegativeInt private constructor(private val number: Int) {
    override fun equals(other: Any?): Boolean = TODO()
    override fun hashCode(): Int = TODO()
    fun toInt(): Int = TODO()
    override fun toString(): String = TODO()

    companion object {
        fun orNull(number: Int): NegativeInt? = TODO()
        fun orThrow(number: Int): NegativeInt = TODO()
    }
}

// In 'org.kotools.types.kotlinx.serialization' package:

fun NegativeInt.Companion.intSerializer(): KSerializer<NegativeInt> = TODO()

βœ… Checklist

  • ✨ Add the type with its private constructor, its Companion.orNull(Int) and toInt() methods with tests, documentation and samples.
  • ✨ Add the NegativeInt.Companion.orThrow(Int) method with tests, documentation and samples.
  • ✨ Override the NegativeInt.toString() method with tests, documentation and samples.
  • ✨ Override the structural equality operations (equals(Any?) and hashCode() methods) of the NegativeInt type with tests, documentation and samples.
  • ✨ Add the NegativeInt.Companion.intSerializer() function with tests, documentation and samples.
  • ✨ Update the KotoolsTypesSerializersModule() function for making the NegativeInt type serializable as Int by default.
  • πŸ“ Update the unreleased changelog for this issue.
  • πŸ“ Create an issue for stabilizing this type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    commonItem related to all platforms.featureNew feature or request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions