io.github.mbannour.mongo.codecs.EnumValueCodecProvider
EnumValueCodecProvider is a helper object to generate a MongoDB org.bson.codecs.configuration.CodecProvider for Scala 3 enums that can be uniquely represented by a single primitive value such as an Int, String, or Boolean.
This allows seamless BSON serialization/deserialization of Scala enums by mapping them to their primitive representation when writing to and reading from MongoDB.
Attributes
Graph
Reset zoom Hide graph Show graph
Supertypes
class Object
trait Matchable
class Any
Self type
Members list
Creates a CodecProvider for a Scala 3 enum type E that can be encoded as a primitive type V (e.g., Int, String).
Creates a CodecProvider for a Scala 3 enum type E that can be encoded as a primitive type V (e.g., Int, String).
Type parameters
E
The enum type. Must be a Scala 3 enum (i.e., subtype of scala.reflect.Enum)
V
The primitive value type to use for MongoDB representation (e.g., Int, String)
Value parameters
fromValue
A function to reconstruct the enum instance (E) from its primitive representation (V)
toValue
A function to extract the primitive representation (V) from the enum instance (E)
valueCodec
An implicit MongoDB Codec for the primitive type V
Attributes
Returns
A CodecProvider that supplies BSON codecs for the enum type E
Creates a CodecProvider for a Scala 3 enum type E that is represented as its ordinal (using its index).
Creates a CodecProvider for a Scala 3 enum type E that is represented as its ordinal (using its index).
Example usage: EnumValueCodecProvider.forOrdinalEnum[Priority]
Attributes
Creates a CodecProvider for a Scala 3 enum type E that is represented as a string (using its name).
Creates a CodecProvider for a Scala 3 enum type E that is represented as a string (using its name).
Example usage: EnumValueCodecProvider.forStringEnum[Priority]
Attributes