For maintaining a good design for Kotlin and Java users, we want to replace existing factory functions by constructors and orNull factory functions. New constructors should be accessible easily from Kotlin and Java code, but orNull factory functions should be only accessible from Kotlin code.
Here's the Application Programming Interface (API) goal:
class Zero {
constructor()
constructor(number: Byte)
constructor(number: Short)
constructor(number: Int)
constructor(number: Long)
constructor(number: Float)
constructor(number: Double)
companion object {
@JvmSynthetic fun orNull(number: Byte): Zero?
@JvmSynthetic fun orNull(number: Short): Zero?
@JvmSynthetic fun orNull(number: Int): Zero?
@JvmSynthetic fun orNull(number: Long): Zero?
@JvmSynthetic fun orNull(number: Float): Zero?
@JvmSynthetic fun orNull(number: Double): Zero?
}
}
✅ Checklist
[ ] ✨ Add the constructor accepting a Byte with tests, documentation and samples.
[ ] ✨ Add the orNull(Byte) function for Kotlin only with tests, documentation and samples.
[ ] 📝 Refer to the constructor accepting a Byte and the orNull(Byte) function in their respective documentation.
[ ] ✨ Add the constructor accepting a Short with tests, documentation and samples.
[ ] ✨ Add the orNull(Short) function for Kotlin only with tests, documentation and samples.
[ ] 📝 Refer to the constructor accepting a Short and the orNull(Short) function in their respective documentation.
[ ] ✨ Add the constructor accepting a Int with tests, documentation and samples.
[ ] ✨ Add the orNull(Int) function for Kotlin only with tests, documentation and samples.
[ ] 📝 Refer to the constructor accepting a Int and the orNull(Int) function in their respective documentation.
[ ] ✨ Add the constructor accepting a Long with tests, documentation and samples.
[ ] ✨ Add the orNull(Long) function for Kotlin only with tests, documentation and samples.
[ ] 📝 Refer to the constructor accepting a Long and the orNull(Long) function in their respective documentation.
[ ] ✨ Add the constructor accepting a Float with tests, documentation and samples.
[ ] ✨ Add the orNull(Float) function for Kotlin only with tests, documentation and samples.
[ ] 📝 Refer to the constructor accepting a Float and the orNull(Float) function in their respective documentation.
[ ] ✨ Add the constructor accepting a Double with tests, documentation and samples.
[ ] ✨ Add the orNull(Double) function for Kotlin only with tests, documentation and samples.
[ ] 📝 Refer to the constructor accepting a Double and the orNull(Double) function in their respective documentation.
[ ] 🔥 Remove the orThrow(Any) function introduced by #668.
[ ] 🔥 Remove the orNull(Any) function introduced by #668.
[ ] 🔥 Remove the PATTERN constant introduced by #658.
[ ] 📝 Update the unreleased changelog for this issue.
📝 Description
For maintaining a good design for Kotlin and Java users, we want to replace existing factory functions by constructors and
orNull
factory functions. New constructors should be accessible easily from Kotlin and Java code, butorNull
factory functions should be only accessible from Kotlin code.Here's the Application Programming Interface (API) goal:
✅ Checklist
Byte
with tests, documentation and samples.orNull(Byte)
function for Kotlin only with tests, documentation and samples.Byte
and theorNull(Byte)
function in their respective documentation.Short
with tests, documentation and samples.orNull(Short)
function for Kotlin only with tests, documentation and samples.Short
and theorNull(Short)
function in their respective documentation.Int
with tests, documentation and samples.orNull(Int)
function for Kotlin only with tests, documentation and samples.Int
and theorNull(Int)
function in their respective documentation.Long
with tests, documentation and samples.orNull(Long)
function for Kotlin only with tests, documentation and samples.Long
and theorNull(Long)
function in their respective documentation.Float
with tests, documentation and samples.orNull(Float)
function for Kotlin only with tests, documentation and samples.Float
and theorNull(Float)
function in their respective documentation.Double
with tests, documentation and samples.orNull(Double)
function for Kotlin only with tests, documentation and samples.Double
and theorNull(Double)
function in their respective documentation.orThrow(Any)
function introduced by #668.orNull(Any)
function introduced by #668.PATTERN
constant introduced by #658.