Packages

c

org.virtuslab.ash.circe

CirceAkkaSerializer

abstract class CirceAkkaSerializer[Ser <: AnyRef] extends SerializerWithStringManifest with CirceTraitCodec[Ser] with AkkaCodecs

An abstract class that is extended to create a custom serializer.

After creating your subclass, don't forget to add your serializer and base trait to application.conf (for more info https://doc.akka.io/docs/akka/current/serialization.html)

Example subclass:

class CustomSerializer(actorSystem: ExtendedActorSystem) extends CirceAkkaSerializer[MySerializable](actorSystem) {

  implicit private val serializabilityCodec: Codec[MySerializable] = genericCodec

  override def identifier: Int = 41

  override lazy val codecs =
    Seq(
      Register[SthCommand],
      Register(implicitly[ru.TypeTag[ModifiedCodec]], prepareEncoder, prepareDecoder),
      Register[GenericClass[MySerializable, MySerializable]])

  override lazy val manifestMigrations = Seq("app.OldName" -> classOf[TopTraitMigration])

  override lazy val packagePrefix = "app"
}
Ser

base trait that is used to mark serialization

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CirceAkkaSerializer
  2. AkkaCodecs
  3. CirceTraitCodec
  4. Codec
  5. Encoder
  6. Decoder
  7. Serializable
  8. SerializerWithStringManifest
  9. Serializer
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CirceAkkaSerializer(system: ExtendedActorSystem)(implicit arg0: ClassTag[Ser])

    system

    ExtendedActorSystem that is provided by Akka

Abstract Value Members

  1. abstract val codecs: Seq[Registration[_ <: Ser]]

    Sequence that must contain org.virtuslab.ash.circe.Registration for all direct subclasses of Ser.

    Sequence that must contain org.virtuslab.ash.circe.Registration for all direct subclasses of Ser.

    Each Registration is created using org.virtuslab.ash.circe.Registers org.virtuslab.ash.circe.Register#apply method.

    To check if all needed classes are registered, use Codec Registration Checker.

    Definition Classes
    CirceTraitCodec
    See also

    org.virtuslab.ash.circe.Registerorg.virtuslab.ash.circe.Register#apply for more information about type derivation

  2. abstract def identifier: Int
    Definition Classes
    SerializerWithStringManifest → Serializer
  3. abstract val manifestMigrations: Seq[(String, Class[_])]

    A sequence containing information used in type migration.

    A sequence containing information used in type migration.

    If you ever change the name of a class that is a direct descendant of Ser and is persisted in any way, you must append new pair to this field.

    • The first element of the pair is a String with the value of old FQCN.
    • The second element of the pair is a Class that had its name changed

    Example:

    override lazy val manifestMigrations = Seq(
     "app.OldName" -> classOf[app.NewName]
    )
    Definition Classes
    CirceTraitCodec
  4. abstract val packagePrefix: String

    Package prefix of your project.

    Package prefix of your project. Ensure that Ser is included in that package and as many classes that extend it.

    It should look something like "org.group.project"

    It is used for some runtime checks that are executed at the end of constructor.

    Definition Classes
    CirceTraitCodec

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. implicit def actorRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[ActorRef[T]]
    Definition Classes
    AkkaCodecs
  5. def apply(a: Ser): Json
    Definition Classes
    CirceTraitCodec → Encoder
  6. def apply(c: HCursor): Result[Ser]
    Definition Classes
    CirceTraitCodec → Decoder
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. final def at(field: String): Decoder[Ser]
    Definition Classes
    Decoder
  9. lazy val classTagEvidence: ClassTag[Ser]
    Definition Classes
    CirceAkkaSerializerCirceTraitCodec
  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  11. val codecsMap: Map[String, (Encoder[_ <: Ser], Decoder[_ <: Ser])]
    Attributes
    protected
    Definition Classes
    CirceTraitCodec
  12. final def contramap[B](f: (B) ⇒ Ser): Encoder[B]
    Definition Classes
    Encoder
  13. def decodeAccumulating(c: HCursor): AccumulatingResult[Ser]
    Definition Classes
    Decoder
  14. final def decodeJson(j: Json): Result[Ser]
    Definition Classes
    Decoder
  15. final def either[B](decodeB: Decoder[B]): Decoder[Either[Ser, B]]
    Definition Classes
    Decoder
  16. final def emap[B](f: (Ser) ⇒ Either[String, B]): Decoder[B]
    Definition Classes
    Decoder
  17. final def emapTry[B](f: (Ser) ⇒ Try[B]): Decoder[B]
    Definition Classes
    Decoder
  18. final def ensure(errors: (Ser) ⇒ List[String]): Decoder[Ser]
    Definition Classes
    Decoder
  19. final def ensure(pred: (Ser) ⇒ Boolean, message: ⇒ String): Decoder[Ser]
    Definition Classes
    Decoder
  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  22. lazy val errorCallback: (String) ⇒ Unit
    Definition Classes
    CirceAkkaSerializerCirceTraitCodec
  23. final def flatMap[B](f: (Ser) ⇒ Decoder[B]): Decoder[B]
    Definition Classes
    Decoder
  24. def fromBinary(bytes: Array[Byte], manifest: String): AnyRef
    Definition Classes
    CirceAkkaSerializer → SerializerWithStringManifest
  25. final def fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef
    Definition Classes
    SerializerWithStringManifest → Serializer
  26. final def fromBinary(bytes: Array[Byte], clazz: Class[_]): AnyRef
    Definition Classes
    Serializer
    Annotations
    @throws( ... )
  27. final def fromBinary(bytes: Array[Byte]): AnyRef
    Definition Classes
    Serializer
  28. def genericCodec: Codec[Ser]

    The intended usage of this method is to provide any form of support for generic classes.

    The intended usage of this method is to provide any form of support for generic classes.

    Because of type erasure, it's impossible to org.virtuslab.ash.circe.Register one generic class two times with different type parameters.

    The trick for combating type erasure is to register generic class only once with type parameter being its upper bound, and provide custom made io.circe.Codec that can serialize/deserialize all classes that are used as a type parameter.

    For example, if the upper bound is Any, but you know that only Int and String are used as a type parameter, then you can create a custom io.circe.Codec for Any that handles Int and String and throws Exception otherwise.

    To use this method correctly, set the upper bound for the type parameter of generic class to Ser and put the returned Codec as implicit in a place that can be seen by type derivation.

    Example of generic class:

    case class GenericClass[A <: MySerializable, B <: MySerializable](a: A, b: B) extends MySerializable

    and its registration in serializer:

    Register[GenericClass[MySerializable, MySerializable]]
    returns

    io.circe.Codec that can serialize all subtypes of Ser

  29. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  30. final def handleErrorWith(f: (DecodingFailure) ⇒ Decoder[Ser]): Decoder[Ser]
    Definition Classes
    Decoder
  31. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  32. def iemap[B](f: (Ser) ⇒ Either[String, B])(g: (B) ⇒ Ser): Codec[B]
    Definition Classes
    Codec
  33. final def includeManifest: Boolean
    Definition Classes
    SerializerWithStringManifest → Serializer
  34. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  35. final def kleisli: Kleisli[Result, HCursor, Ser]
    Definition Classes
    Decoder
  36. def manifest(o: AnyRef): String
    Definition Classes
    CirceTraitCodec
  37. val manifestMigrationsMap: Map[String, String]
    Attributes
    protected
    Definition Classes
    CirceTraitCodec
  38. final def map[B](f: (Ser) ⇒ B): Decoder[B]
    Definition Classes
    Decoder
  39. final def mapJson(f: (Json) ⇒ Json): Encoder[Ser]
    Definition Classes
    Encoder
  40. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  41. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  42. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  43. final def or[AA >: Ser](d: ⇒ Decoder[AA]): Decoder[AA]
    Definition Classes
    Decoder
  44. final def prepare(f: (ACursor) ⇒ ACursor): Decoder[Ser]
    Definition Classes
    Decoder
  45. final def product[B](fb: Decoder[B]): Decoder[(Ser, B)]
    Definition Classes
    Decoder
  46. implicit def sinkRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[SinkRef[T]]
    Definition Classes
    AkkaCodecs
  47. implicit def sourceRefCodec[T](implicit system: ActorSystem = serializationSystem): Codec[SourceRef[T]]
    Definition Classes
    AkkaCodecs
  48. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  49. def toBinary(o: AnyRef): Array[Byte]
    Definition Classes
    CirceAkkaSerializer → SerializerWithStringManifest → Serializer
  50. def toString(): String
    Definition Classes
    AnyRef → Any
  51. def tryDecode(c: ACursor): Result[Ser]
    Definition Classes
    Decoder
  52. def tryDecodeAccumulating(c: ACursor): AccumulatingResult[Ser]
    Definition Classes
    Decoder
  53. final def validate(pred: (HCursor) ⇒ Boolean, message: ⇒ String): Decoder[Ser]
    Definition Classes
    Decoder
  54. final def validate(errors: (HCursor) ⇒ List[String]): Decoder[Ser]
    Definition Classes
    Decoder
  55. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  57. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. final def withErrorMessage(message: String): Decoder[Ser]
    Definition Classes
    Decoder

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AkkaCodecs

Inherited from CirceTraitCodec[Ser]

Inherited from Codec[Ser]

Inherited from Encoder[Ser]

Inherited from Decoder[Ser]

Inherited from Serializable

Inherited from Serializer

Inherited from AnyRef

Inherited from Any

Ungrouped