Use value classes instead of strings/primitives

Instead of taking a Collection.get() taking a id: String , make it take id: DocumentId

@JvmInline
value class DocumentId(val id: String) {
    init {  require(id.isNotEmpty()) { "Document ID must not be empty." } }
}

Use value classes through out the API to make it more strongly typed.

Hi Michael,

This is an interesting idea. We’ll have to weigh it against convenience. That is to say,

collection.get(DocumentId("foo"))

is perhaps less elegant than

collection.get("foo")

or

collection.get(id = "foo")

It’s easier to weigh in favor of value classes when they add behavior to the value… but sometimes a String is just a String.

Maybe it would help for us to look at an existing API that makes extensive use of value classes. Is there an API you like that uses this technique?

Thanks,
David