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 Zero type #644

Closed
9 tasks done
Tracked by #646 ...
LVMVRQUXL opened this issue Apr 13, 2024 · 4 comments
Closed
9 tasks done
Tracked by #646 ...

✨ New Zero type #644

LVMVRQUXL opened this issue Apr 13, 2024 · 4 comments
Assignees
Labels
common Item related to all platforms. feature New feature or request.
Milestone

Comments

@LVMVRQUXL
Copy link
Contributor

LVMVRQUXL commented Apr 13, 2024

📝 Description

We want to introduce a Zero experimental type, in the org.kotools.types package of the types Gradle subproject, for representing the zero number.

This type should have the following Application Programming Interface (API):

interface Zero {
    override fun equals(other: Any?): Boolean
    override fun hashCode(): Int
    fun toByte(): Byte
    override fun toString(): String

    companion object {
        fun fromByte(number: Byte): Zero = TODO()
        fun fromByteOrNull(number: Byte): Zero? = TODO()
    }
}

The serialization and deserialization processes of this type should behave like for the Byte type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:

val format = Json { serializersModule = KotoolsTypesSerializers.zero }
val zero = Zero()
val encoded: String = format.encodeToString(zero)
println(encoded) // 0
val decoded: Zero = format.decodeFromString(encoded)
println(zero == decoded) // true

🕓 Commit history

Here's the history of commits related to this type made before the existence of this issue: 2df18e4, 43ee104, 5cfccae, 5cf8149, b031be2, e894ff7, d59f69e, 4d4fea9, f79a220, 5793ba6, c6e6a5e, fb29426 and f60d455.

✅ Checklist

  • 📝 Reference this issue in related entries of the unreleased changelog.
  • 💥 Convert the type from object to class, refactor usages and dump the Application Binary Interface (ABI).
  • ✨ Override the structural equality operations (equals and hashCode) with tests, documentation and samples, then dump the ABI.
  • ♻️ Refactor samples of the KotoolsTypesSerializers.zero property for using the Zero.equals override.
  • ♻️ Refactor samples of the KotoolsTypesSerializers.all property for using the Zero.equals override.
  • ✨ Add the Zero.Companion.fromByteOrNull function with tests, documentation and samples, then dump the ABI.
  • ✨ Add the Zero.Companion.fromByte function with tests, documentation and samples, then dump the ABI.
  • ♻️ Refactor the ZeroAsByteSerializer.deserialize function for using the Zero.Companion.fromByteOrNull function.
  • 📝 Create an issue for stabilizing this type.
@LVMVRQUXL LVMVRQUXL added feature New feature or request. common Item related to all platforms. labels Apr 13, 2024
@LVMVRQUXL LVMVRQUXL added this to the 4.6.0 milestone Apr 13, 2024
LVMVRQUXL added a commit that referenced this issue Apr 14, 2024
Converts this property as getter.

Gradle projects: types-kotlinx-serialization.
References: #602 and #644.
@LVMVRQUXL LVMVRQUXL self-assigned this Apr 14, 2024
LVMVRQUXL added a commit that referenced this issue Apr 15, 2024
Gradle projects: types-internal and types-kotlinx-serialization.
References: #602 and #644.
LVMVRQUXL added a commit that referenced this issue Apr 15, 2024
@LVMVRQUXL

This comment was marked as resolved.

@LVMVRQUXL LVMVRQUXL reopened this Apr 17, 2024
LVMVRQUXL added a commit that referenced this issue Apr 17, 2024
Converts this type for providing a better instances management.
LVMVRQUXL added a commit that referenced this issue Apr 17, 2024
Overrides the `equals(Any?)` and the `hashCode()` functions of this type.
LVMVRQUXL added a commit that referenced this issue Apr 17, 2024
Refactors this type by extracting the deserialization error in a new `DeserializationError` type.
@LVMVRQUXL

This comment was marked as duplicate.

@LVMVRQUXL

This comment was marked as resolved.

LVMVRQUXL added a commit that referenced this issue Apr 22, 2024
Updates the message of the exception thrown when deserializing the `Zero` type from a value fails.
@LVMVRQUXL

This comment was marked as duplicate.

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