Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ New orNull and orThrow functions in StrictlyPositiveInt.Companion type #770

Closed
14 tasks
Tracked by #774
LVMVRQUXL opened this issue Jan 12, 2025 · 1 comment
Closed
14 tasks
Tracked by #774
Labels
common Item related to all platforms. feature New feature or request.

Comments

@LVMVRQUXL
Copy link
Contributor

LVMVRQUXL commented Jan 12, 2025

πŸ“ Description

We want to introduce the orNull and the orThrow experimental factory functions in the StrictlyPositiveInt.Companion type, for creating an instance of StrictlyPositiveInt from the specified number of type Byte, Short, Int, Long, Float or Double.

interface StrictlyPositiveInt {
    companion object {
        fun orNull(number: Byte): StrictlyPositiveInt? = TODO()
        fun orNull(number: Short): StrictlyPositiveInt? = TODO()
        fun orNull(number: Int): StrictlyPositiveInt? = TODO()
        fun orNull(number: Long): StrictlyPositiveInt? = TODO()
        fun orNull(number: Float): StrictlyPositiveInt? = TODO()
        fun orNull(number: Double): StrictlyPositiveInt? = TODO()
        
        fun orThrow(number: Byte): StrictlyPositiveInt = TODO()
        fun orThrow(number: Short): StrictlyPositiveInt = TODO()
        fun orThrow(number: Int): StrictlyPositiveInt = TODO()
        fun orThrow(number: Long): StrictlyPositiveInt = TODO()
        fun orThrow(number: Float): StrictlyPositiveInt = TODO()
        fun orThrow(number: Double): StrictlyPositiveInt = TODO()
    }
}

These factory functions should be available for all platforms, except for the orNull function that shouldn't be accessible from Java, due to its non-explicit support for nullable types.

βœ… Checklist

See the Issue implementation section in the contributing guidelines before addressing the following checklist.

  • ✨ Add the orThrow(Byte) function for Kotlin and Java with tests, documentation and samples.
  • ✨ Add the orNull(Byte) function for Kotlin with tests, documentation and samples.
  • ✨ Add the orThrow(Short) function for Kotlin and Java with tests, documentation and samples.
  • ✨ Add the orNull(Short) function for Kotlin with tests, documentation and samples.
  • ✨ Add the orThrow(Int) function for Kotlin and Java with tests, documentation and samples.
  • ✨ Add the orNull(Int) function for Kotlin with tests, documentation and samples.
  • ✨ Add the orThrow(Long) function for Kotlin and Java with tests, documentation and samples.
  • ✨ Add the orNull(Long) function for Kotlin with tests, documentation and samples.
  • ✨ Add the orThrow(Float) function for Kotlin and Java with tests, documentation and samples.
  • ✨ Add the orNull(Float) function for Kotlin with tests, documentation and samples.
  • ✨ Add the orThrow(Double) function for Kotlin and Java with tests, documentation and samples.
  • ✨ Add the orNull(Double) function for Kotlin with tests, documentation and samples.
  • πŸ“ Update the unreleased changelog for this issue.
  • πŸ“ After closing this issue, attach tracking issues to a milestone.
@LVMVRQUXL
Copy link
Contributor Author

A better alternative of the StrictlyPositiveInt type will be added in the org.kotools.types package (#661), so it is not necessary to add declarations to this type.

@LVMVRQUXL LVMVRQUXL closed this as not planned Won't fix, can't repro, duplicate, stale Mar 17, 2025
@LVMVRQUXL LVMVRQUXL removed this from the Ready milestone Mar 17, 2025
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

No branches or pull requests

1 participant