Skip to content

Conversation

LVMVRQUXL
Copy link
Contributor

@LVMVRQUXL LVMVRQUXL commented Sep 25, 2025

📝 Description

This request introduces the PositiveInteger experimental type, in the org.kotools.types package from the types module, for representing an integer that is greater than zero.

Contrarily to the integer types provided by Kotlin (Byte, Short, Int and Long), this type has no maximum value and can hold greater values than Long.MAX_VALUE.

The PositiveInteger type is available on all platforms supported by Kotools Types.

Instance creation

This request adds the PositiveInteger.Companion.of function for creating an instance of the PositiveInteger type from String.

Extension functions on Int and Long will be introduced while implementing this request.

PositiveInteger of "123456789"
PositiveInteger of "+123456789"

✅ Checklist

  • ✨ Add the PositiveInteger type as value class with private constructor and documentation.
  • ✨ Add the PositiveInteger.of(String) function with tests, documentation and samples.
  • ✨ Override the PositiveInteger.toString() function with documentation, samples and tests.
  • ✨ Add the PositiveInteger.of(Int) function with tests, documentation and samples.
  • ✨ Add the PositiveInteger.of(Long) function with tests, documentation and samples.
  • ✨ Make the PositiveInteger type serializable as String.
  • 📝 Update the unreleased changelog for this request.
  • 📝 Update this request's description before marking it ready.

➡️ What's coming next

  • ✨ Add PositiveIntegerFormat type and the PositiveInteger.toString(PositiveIntegerFormat.() -> Unit) extension function, for returning the formatted string representation of this positive integer. The PositiveIntegerFormat.thousandsSeparator() function must follow the ISO 31-0 standard by using the space character ( ) as thousands separator.
val result: String = "123456789".toPositiveInteger().toString {
    signed()
    thousandsSeparator()
}
println(result) // +123 456 789
  • ✨ Make the PositiveInteger type comparable with PositiveInteger, Int and Long types.

@LVMVRQUXL LVMVRQUXL self-assigned this Sep 25, 2025
@LVMVRQUXL LVMVRQUXL added feature New feature or request. common Item related to all platforms. labels Sep 25, 2025
@LVMVRQUXL LVMVRQUXL force-pushed the feature/positive-integer branch from f1772f8 to 3be6458 Compare September 28, 2025 15:34
@LVMVRQUXL
Copy link
Contributor Author

We will not introduce the PositiveInteger type before fixing the number types existing in the kotools.types.number package.

@LVMVRQUXL LVMVRQUXL closed this Oct 3, 2025
@LVMVRQUXL LVMVRQUXL deleted the feature/positive-integer branch October 3, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Item related to all platforms. feature New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant