Class BsonPlugin

java.lang.Object
io.vena.bosk.SerializationPlugin
io.vena.bosk.drivers.mongo.BsonPlugin

public final class BsonPlugin extends io.vena.bosk.SerializationPlugin
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.vena.bosk.SerializationPlugin

    io.vena.bosk.SerializationPlugin.DeserializationScope
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <R extends io.vena.bosk.StateTreeNode>
    org.bson.codecs.configuration.CodecProvider
    codecProviderFor(io.vena.bosk.Bosk<R> bosk)
    Note that the CodecProvider is Class-based, so it has anemic type information for generics due to type erasure.
    <T, R extends io.vena.bosk.StateTreeNode>
    org.bson.codecs.Codec<T>
    getCodec(Type targetType, Class<T> targetClass, org.bson.codecs.configuration.CodecRegistry registry, io.vena.bosk.Bosk<R> bosk)
    Like codecProviderFor(bosk).get(targetType, registry) except this works more broadly because it can accept a ParameterizedType for generic classes.

    Methods inherited from class io.vena.bosk.SerializationPlugin

    entryDeserializationScope, hasDeserializationPath, initializeEnclosingPolyfills, isEnclosingReference, isImplicitParameter, isSelfReference, newDeserializationScope, newDeserializationScope, nodeFieldDeserializationScope, overlayScope, parameterValueList

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BsonPlugin

      public BsonPlugin()
  • Method Details

    • codecProviderFor

      public <R extends io.vena.bosk.StateTreeNode> org.bson.codecs.configuration.CodecProvider codecProviderFor(io.vena.bosk.Bosk<R> bosk)
      Note that the CodecProvider is Class-based, so it has anemic type information for generics due to type erasure. Because of this, the returned CodecProvider is unable to provide Codecs for certain generic types.

      In response to this shortcoming, you can access Codecs for any type using getCodec(Type, Class, CodecRegistry, Bosk)

    • getCodec

      public <T, R extends io.vena.bosk.StateTreeNode> org.bson.codecs.Codec<T> getCodec(Type targetType, Class<T> targetClass, org.bson.codecs.configuration.CodecRegistry registry, io.vena.bosk.Bosk<R> bosk)
      Like codecProviderFor(bosk).get(targetType, registry) except this works more broadly because it can accept a ParameterizedType for generic classes.
      Type Parameters:
      R - root type of bosk
      Parameters:
      targetClass - must match targetType. This is provided only to help Java do type inference and avoid ugly and unnecessary type casts.