Skip to content

Commit

Permalink
added convenience method as[T] onto ParameterSpec for automatic seria…
Browse files Browse the repository at this point in the history
…lisation/deserialisation of case class instances. Example use: ParameterSpec.int().as[IntCaseClassWithAnyVal]
  • Loading branch information
daviddenton committed Feb 1, 2017
1 parent 1362255 commit d33df80
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ case class ParameterSpec[T](paramType: ParamType,
/**
* Convenience method for avoiding using map() with AnyVal case-classes. Due to the Scala type system,
* this method provides no compile-time safety as to if the signatures are compatible (ie. it won't complain at
* ParameterSpec.int().as[MyStringAnyVal]. However, obviously a runtime exception will be generated.
* ParameterSpec.int().as[MyStringAnyVal]. However, obviously a runtime exception will be generated, since this method
* use reflection to get the value of the underlying case-class value
* @tparam Wrapper - the value type of the case class AnyVal
*/
def as[Wrapper <: AnyVal with Product](implicit mf: Manifest[Wrapper]): ParameterSpec[Wrapper] = {
Expand Down

0 comments on commit d33df80

Please sign in to comment.