Use getDiscriminatedUnionEncoder instead.