Skip to content

Releases: alexarchambault/data-class

v0.2.7

20 Jan 13:54

Choose a tag to compare

What's Changed

Updates / maintenance

Full Changelog: v0.2.6...v0.2.7

v0.2.6

12 Aug 16:06

Choose a tag to compare

Updates / maintainance

New Contributors

Full Changelog: v0.2.5...v0.2.6

v0.2.5

13 Nov 15:24
8877404

Choose a tag to compare

v0.2.5 Pre-release
Pre-release

New features

Allow to cache hash codes

Use like

@data(cachedHashCode = true) class Foo(n: Int, s: String)

The hashCode method of Foo is then implemented via a lazy val hashCode = ….

Added in #52, thanks to @oyvindberg.

v0.2.4

31 Oct 18:40
1c44e9a

Choose a tag to compare

v0.2.4 Pre-release
Pre-release

Optimization

Use reference equality in generated equals methods

The implementation of equals now compares upfront the values it's given with reference equality. If we are passed the exact same instances, equals returns true, and the fields are not compared one-by-one. Else, the two instances are compared as before.

Added in #48, thanks to @jtjeferreira.

New features

Allow to call apply instead of new in generated with* methods

Passing settersCallApply = true to the @data annotation, like @data(settersCallApply = true), makes it generate with* methods that call apply rather than new to create new instances. Used alongside apply = false, this allows to create instances via a custom apply method, where you can write more complex logic (memoization, etc.).

Added in #49, thanks to @jtjeferreira.

v0.2.3

27 Apr 12:12
d95266a

Choose a tag to compare

v0.2.3 Pre-release
Pre-release
  • Allow to generate more convenient setters for option fields (#19)

Use like

@data(optionSetters = true)
class Foo(n: Option[Int] = None)

Foo()
  .withN(2) // wrapping in Some(…) is optional

v0.2.2

18 Mar 15:00
d254b4a

Choose a tag to compare

v0.2.2 Pre-release
Pre-release

Fixes

Don't let Nothing be inferred for type parameters of data classes, when these type parameters aren't used by any of the fields. The following now works for example:

@data class Bar[T](n: Int, s: String)
val barI = Bar[Int](2, "a")
val barNewN = barI.withN(3) // typed as Bar[Int] rather than Bar[Nothing]

Fixed in #14, thanks to @regadas.

v0.2.1

08 Dec 14:19
d738787

Choose a tag to compare

v0.2.1 Pre-release
Pre-release
  • Implement the productPrefix and productElementName methods of scala.Product (fixes empty names when printing data classes with PPrint, in Ammonite for example)

v0.2.0

13 Oct 18:13
0d4768f

Choose a tag to compare

v0.2.0 Pre-release
Pre-release
  • Fix weird 2.11 issues (with override val fields, or classpath issues when using data-class as a provided dependency)
  • Make constructors public by default (as some constructors always ended-up being public according to javap, making them all public allows not to break binary compatibility upon field addition)

v0.1.6

09 Oct 14:24
56152b7

Choose a tag to compare

v0.1.6 Pre-release
Pre-release
  • Don't generate apply methods if constructor is explicitly private (like in @data class Foo private (n: Int))

v0.1.5

08 Oct 13:55
8e903e7

Choose a tag to compare

v0.1.5 Pre-release
Pre-release
  • Add basic support for multiple parameter groups (departing from how they're handled in case classes - parameters of the extra groups are considered just like the ones of the first group, with setters / accessors, they're read in equals / hashCode and in the Product methods, etc.)