
com.avsystem.commons.serialization.transientDefault.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-annotations_2.12.0-RC1 Show documentation
Show all versions of commons-annotations_2.12.0-RC1 Show documentation
AVSystem commons library for Scala
The newest version!
package com.avsystem.commons
package serialization
import scala.annotation.StaticAnnotation
/**
* If some case class field has default value, you can use this annotation 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.
*/
class transientDefault extends StaticAnnotation
© 2015 - 2025 Weber Informatics LLC | Privacy Policy