private function getDiscriminatorData(array $referenceMapping, ClassMetadata $class) : array
    {
        $discriminatorField = null;
        $discriminatorValue = null;
        $discriminatorMap   = null;

        if (isset($referenceMapping['discriminatorField'])) {
            $discriminatorField = $referenceMapping['discriminatorField'];

            if (isset($referenceMapping['discriminatorMap'])) {
                $discriminatorMap = $referenceMapping['discriminatorMap'];
            }
        } else {
            $discriminatorField = $class->discriminatorField;
            $discriminatorValue = $class->discriminatorValue;
            $discriminatorMap   = $class->discriminatorMap;
        }

        if ($discriminatorField === null) {
            return [];
        }

        if ($discriminatorValue === null) {
            if (! empty($discriminatorMap)) {
                $pos = array_search($class->name, $discriminatorMap);

                if ($pos !== false) {
                    $discriminatorValue = $pos;
                }
            } else {
                $discriminatorValue = $class->name;
            }
        }

        if ($discriminatorValue === null) {
            throw MappingException::unlistedClassInDiscriminatorMap($class->name);
        }

        return [$discriminatorField => $discriminatorValue];
    }