All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avsystem.commons.serialization.transientDefault.scala Maven / Gradle / Ivy

There is a newer version: 2.22.0
Show newest version
package com.avsystem.commons
package serialization

/**
  * If some case class field has default value or [[whenAbsent]] annotation, you can use [[transientDefault]]
  * on this field to instruct an automatically derived `GenCodec` to not persist the value of that field if
  * it's equal to the default value.
  *
  * For example:
  * {{{
  *   case class Something(str: String, @transientDefault int: Int = 42)
  *   object Something {
  *     implicit val codec = GenCodec.auto[Something]
  *   }
  * }}}
  *
  * `GenCodec.write(someOutput, Something("lol", 10))` would yield object `{"str": "lol", "int": 10}` but
  * `GenCodec.write(someOutput, Something("lol", 42))` would yield object `{"str": "lol"}` because the value of `int`
  * is the same as the default value.
  *
  * NOTE: [[transientDefault]] also works for method parameters in RPC framework.
  */
class transientDefault extends StaticAnnotation




© 2015 - 2025 Weber Informatics LLC | Privacy Policy