BeanPurée 0.2 release announcement

Posted on August 9, 2017

I’m happy to announce the second release of BeanPurée library.

The main goal of this release is to make BeanConverter more intelligent. Previously, it required you to have the same type for the corresponding fields in a bean and a product. If there are Java number classes in your beans, it’s possible you don’t want to use it in your Scala code. Instead, you would like to use Options, or you may know that these values are never null.

Now BeanConverter can do these kinds of transformations for you.

JavaTypeMapper type class was introduced to acheive that. It provides two-way conversions for the following cases:

  • Java number class to Scala type. E.g. Integer to Int, or java.math.BigDecimal to scala.math.BigDecimal. If Java value is null it throws NullPointerException.
  • A class T to an Option[T]. Wraps nullable to Option.
  • A class T for which an instance of JavaTypeMapper to class U is available to an Option[U]. For example it is used to convert Integer to Option[Int].
  • HList of the elements which can be mapped with JavaTypeMappers, to HList of mapped values.

If you want to have a previous behavior from BeanConverter use StrictBeanConverter class.