Package de.bild.codec
Class CollectionTypeCodec<C extends Collection<V>,V>
java.lang.Object
de.bild.codec.AbstractTypeCodec<C>
de.bild.codec.CollectionTypeCodec<C,V>
- Type Parameters:
C- collection typeV- value type
- All Implemented Interfaces:
TypeCodec<C>,org.bson.codecs.Codec<C>,org.bson.codecs.Decoder<C>,org.bson.codecs.Encoder<C>
- Direct Known Subclasses:
ListTypeCodec,SetTypeCodec
This codec encodes/decodes any Set and Map (see sub classes)
Note that this codec will never persist any addition properties declared in sub classes
Solely the collection values itself will be persisted.
The advantage is to keep declared methods of Collecton sub classes.
If you really need to persist additional fields with your map, think about using composition over inheritance.
Use a container class that holds a reference to a Collection.
-
Constructor Summary
ConstructorsConstructorDescriptionCollectionTypeCodec(Class<C> collectionClass, Type valueType, TypeCodecRegistry typeCodecRegistry) -
Method Summary
Modifier and TypeMethodDescriptiondecode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext) Override this method if your Codec needs to supply default values as replacements for null values.voidprotected Constructor<C>getDefaultConstructor(Class<C> clazz) Methods inherited from class de.bild.codec.AbstractTypeCodec
getEncoderClass, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.bild.codec.TypeCodec
documentHasId, generateIdIfAbsentFromDocument, getDecodingPojoFailureStrategy, getDocumentId, getTypeFilter, isCollectible
-
Constructor Details
-
CollectionTypeCodec
public CollectionTypeCodec(Class<C> collectionClass, Type valueType, TypeCodecRegistry typeCodecRegistry)
-
-
Method Details
-
decode
-
encode
public void encode(org.bson.BsonWriter writer, C values, org.bson.codecs.EncoderContext encoderContext) -
defaultInstance
Description copied from interface:TypeCodecOverride this method if your Codec needs to supply default values as replacements for null values.- Returns:
- null or a default value
-
getDefaultConstructor
- Overrides:
getDefaultConstructorin classAbstractTypeCodec<C extends Collection<V>>
-
newInstance
- Overrides:
newInstancein classAbstractTypeCodec<C extends Collection<V>>
-