private function createSerializerDelegate(
            Annotations $annotations,
            string $defaultTagName
    ): XmlSerializerDelegate {
        if ($annotations->contain('XmlAttribute')) {
            $xmlAttribute = $annotations->firstNamed('XmlAttribute');
            return new Attribute(
                    $xmlAttribute->attributeName(),
                    $xmlAttribute->getValueByName('skipEmpty', true)
            );
        } elseif ($annotations->contain('XmlFragment')) {
            $xmlFragment = $annotations->firstNamed('XmlFragment');
            return new Fragment(
                    false !== $xmlFragment->tagName() ? $xmlFragment->tagName() : null,
                    $xmlFragment->getValueByName('transformNewLineToBr', false)
            );
        } elseif ($annotations->contain('XmlTag')) {
            $xmlTag = $annotations->firstNamed('XmlTag');
            return new Tag(
                    false !== $xmlTag->tagName() ? $xmlTag->tagName() : '',
                    $xmlTag->getValueByName('elementTagName')
            );
        }

        return new Tag($defaultTagName);
    }