Class < ? > getAndSerializeEffectiveTypeIfRequired ( Object value , Class < ? > declaredType ) throws IOException { Class < ? > realType = value . getClass ( ) ; Class < ? > effectiveType = declaredType ; if ( declaredType == Object . class ) { if ( realType != String . class ) { effectiveType = settings . getConverter ( ) . findTypedConverter ( realType ) . getEffectiveType ( ) ; output . writeMapHeader ( 1 ) ; String type = SerTypeMapper . encodeType ( effectiveType , settings , basePackage , knownTypes ) ; output . writeExtensionString ( MsgPack . JODA_TYPE_DATA , type ) ; } else { effectiveType = realType ; } } else if ( settings . getConverter ( ) . isConvertible ( declaredType ) == false ) { effectiveType = settings . getConverter ( ) . findTypedConverter ( realType ) . getEffectiveType ( ) ; output . writeMapHeader ( 1 ) ; String type = SerTypeMapper . encodeType ( effectiveType , settings , basePackage , knownTypes ) ; output . writeExtensionString ( MsgPack . JODA_TYPE_DATA , type ) ; } return effectiveType ; }
needs to handle no declared type and subclass instances