Package de.bild.codec
Class PolymorphicReflectionCodec<T>
java.lang.Object
de.bild.codec.PolymorphicReflectionCodec<T>
- All Implemented Interfaces:
TypeCodec<T>,org.bson.codecs.Codec<T>,org.bson.codecs.Decoder<T>,org.bson.codecs.Encoder<T>
-
Constructor Summary
ConstructorsConstructorDescriptionPolymorphicReflectionCodec(Type type, Set<Type> validTypes, TypeCodecRegistry typeCodecRegistry, PojoContext pojoContext) -
Method Summary
Modifier and TypeMethodDescriptiondecode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext) protected TdecodeWithType(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext, PolymorphicCodec<T> polymorphicCodec) booleandocumentHasId(T document) voidgenerateIdIfAbsentFromDocument(T document) getCodecForClass(Class<?> clazz) Walks up class hierarchy until a registered codec (in the context of registered model classes) is foundorg.bson.BsonValuegetDocumentId(T document) org.bson.conversions.BsonExample:Or Filter{ filters=[ Filter{fieldName='_t', value=Square}, Filter{fieldName='_discriminatorKey', value=Circle} ] }booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.bild.codec.TypeCodec
defaultInstance, getDecodingPojoFailureStrategy
-
Constructor Details
-
PolymorphicReflectionCodec
public PolymorphicReflectionCodec(Type type, Set<Type> validTypes, TypeCodecRegistry typeCodecRegistry, PojoContext pojoContext)
-
-
Method Details
-
decode
- Specified by:
decodein interfaceorg.bson.codecs.Decoder<T>
-
decodeWithType
protected T decodeWithType(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext, PolymorphicCodec<T> polymorphicCodec) -
encode
public void encode(org.bson.BsonWriter writer, T value, org.bson.codecs.EncoderContext encoderContext) - Specified by:
encodein interfaceorg.bson.codecs.Encoder<T>
-
getCodecForClass
Walks up class hierarchy until a registered codec (in the context of registered model classes) is found- Returns:
- a codec responsible for a valid class within the class hierarchy
-
getEncoderClass
- Specified by:
getEncoderClassin interfaceorg.bson.codecs.Encoder<T>
-
isCollectible
public boolean isCollectible()- Specified by:
isCollectiblein interfaceTypeCodec<T>
-
generateIdIfAbsentFromDocument
- Specified by:
generateIdIfAbsentFromDocumentin interfaceTypeCodec<T>
-
documentHasId
- Specified by:
documentHasIdin interfaceTypeCodec<T>
-
getDocumentId
- Specified by:
getDocumentIdin interfaceTypeCodec<T>
-
getTypeFilter
public org.bson.conversions.Bson getTypeFilter()Example:Or Filter{ filters=[ Filter{fieldName='_t', value=Square}, Filter{fieldName='_discriminatorKey', value=Circle} ] }- Specified by:
getTypeFilterin interfaceTypeCodec<T>- Returns:
- the filter needed to find all types this codec is responsible for
-