Skip to content

✨ Making EmailAddress comparable alphabetically #595

@LVMVRQUXL

Description

@LVMVRQUXL

πŸ“ Description

Similarly to the NotBlankString type, we would like to make the EmailAddress type comparable alphabetically by inheriting the Comparable interface.

interface EmailAddress : Comparable<EmailAddress> {
    override fun compareTo(other: EmailAddress): Int
}

Here's an example of comparing two email addresses from Kotlin code:

val first = EmailAddress.create("first@kotools.org")
val second = EmailAddress.create("second@kotools.org")
println(first < second) // true

Here's an example of comparing two email addresses from Java code:

final EmailAddress first = EmailAddress.Companion.create("first@kotools.org");
final EmailAddress second = EmailAddress.Companion.create("second@kotools.org");
System.out.println(first < second); // true

βœ… Checklist

  • Make the type comparable, test its compareTo function on Kotlin and Java, update the public API binaries and the unreleased changelog.
  • Close this issue as completed and update tracking ones if present.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions