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

Efficiently support value classes #50

Closed
searler opened this issue Aug 11, 2016 · 0 comments
Closed

Efficiently support value classes #50

searler opened this issue Aug 11, 2016 · 0 comments

Comments

@searler
Copy link

searler commented Aug 11, 2016

This example

class Wrapper(val underlying: Int) extends AnyVal
case class Test(i:Int,w:Wrapper)
 AvroSchema[Test].toString(true)

Generates a complex record representation

{
  "type" : "record",
  "name" : "Test",
  "fields" : [ {
    "name" : "i",
    "type" : "int"
  }, {
    "name" : "w",
    "type" : {
      "type" : "record",
      "name" : "Wrapper",
      "fields" : [ {
        "name" : "underlying",
        "type" : "int"
      } ]
    }
  } ]
}

It would best if the schema simply represented w by the underlying int type.

Value classes are very useful, providing type-safety and domain operations without any run-time cost..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants