protected final CodeBlock generateTypeInfo( BeanTypeInfo typeInfo ) {
Class type;
ImmutableMap<JClassType, String> mapTypeToMetadata;
if ( isSerializer() ) {
type = TypeSerializationInfo.class;
mapTypeToMetadata = typeInfo.getMapTypeToSerializationMetadata();
} else {
type = TypeDeserializationInfo.class;
mapTypeToMetadata = typeInfo.getMapTypeToDeserializationMetadata();
}
CodeBlock.Builder builder = CodeBlock.builder()
.add( "new $T($T.$L, $S)", type, As.class, typeInfo.getInclude(), typeInfo.getPropertyName() )
.indent()
.indent();
for ( Entry<JClassType, String> entry : mapTypeToMetadata.entrySet() ) {
builder.add( "\n.addTypeInfo($T.class, $S)", rawName( entry.getKey() ), entry.getValue() );
}
return builder.unindent().unindent().build();
}