Skip to content

Releases: sbt/contraband

0.2.8

15 Nov 22:59
v0.2.8
ae82ec6
Compare
Choose a tag to compare

breaking changes

  • Removes use of default arguments and therefore the copy overloads. #48/#50 by @dwijnand

enhancements

  • Adds generating extra code for companion objects (in Scala) using the "extraCompanion" key #45 by @dwijnand
  • Adds defining class parents and companion object parents (in Scala) using the "parents" and "parentsCompanion" keys. #46 by @dwijnand
  • Adds multi-line support to the custom toString support. #47 by @dwijnand

0.2.7

07 Nov 11:02
v0.2.7
f8dc0ba
Compare
Choose a tag to compare

enhancements

  • Adds generating an empty companion object for abstract classes so that it can be target for enrich-my-type. #40 by @dwijnand
  • Adds support for custom toString using the key "toString". #39/#41 by @dwijnand

0.2.6

27 Oct 04:03
v0.2.6
Compare
Choose a tag to compare

enhancements

  • Adds support for public, overloaded, bincompat copy. See below. #38 by @dwijnand

copy

sbt-datatype 0.2.6 adds support for public, overloaded, binary compatible copy methods (previous there was only
one private[this] copy method.

Defining a record as such:

{
  "name": "Foo",
  "target": "Scala",
  "type": "record",
  "fields": [
    {
      "name": "x",
      "type": "int",
      "since": "0.1.0",
      "default": "0"
    },
    {
      "name": "y",
      "type": "int",
      "since": "0.2.0",
      "default": "0"
    }
  ]
}

will now generate a class like this:

final class Foo(
  val x: Int,
  val y: Int) extends Serializable {
  def this() = this(0, 0)
  def this(x: Int) = this(x, 0)
  override def equals(o: Any): Boolean = o match {
    case x: Foo => (this.x == x.x) && (this.y == x.y)
    case _ => false
  }
  override def hashCode: Int = {
    37 * (37 * (17 + x.##) + y.##)
  }
  override def toString: String = {
    "Foo(" + x + ", " + y + ")"
  }
  def copy(): Foo = {
    new Foo(x, y)
  }
  def copy(x: Int): Foo = {
    new Foo(x, y)
  }
  def copy(x: Int = x, y: Int = y): Foo = {
    new Foo(x, y)
  }
  def withX(x: Int): Foo = {
    copy(x = x)
  }
  def withY(y: Int): Foo = {
    copy(y = y)
  }
}
object Foo {
  def apply(): Foo = new Foo(0, 0)
  def apply(x: Int): Foo = new Foo(x, 0)
  def apply(x: Int, y: Int): Foo = new Foo(x, y)
}

0.2.5

27 Oct 04:04
v0.2.5
Compare
Choose a tag to compare

bug fixes

  • Generate codec for recursive structures. #35 by @Duhemm