Source:
<code>static void parseEmbeddedElement(ObjectTypeAttributeDefinition attribute, XMLExtendedStreamReader reader, ModelNode op, String... additionalExpectedAttributes) throws XMLStreamException { AttributeDefinition[] valueTypes = attribute.getValueTypes(); Map<String, AttributeDefinition> attributes = new HashMap<>(); for (AttributeDefinition valueType : valueTypes) { if (attributes.put(valueType.getXmlName(), valueType) != null) { <START> throw new IllegalStateException("Duplicate key"); <END> } } Map<String, AttributeDefinition> attributeElements = new HashMap<>(); for (AttributeDefinition attributeDefinition : valueTypes) { if (attributeDefinition.getParser().isParseAsElement()) { if (attributeElements.put(attributeDefinition.getParser().getXmlName(attributeDefinition), attributeDefinition) != null) { throw new IllegalStateException("Duplicate key"); } } } for (int i = 0; i < reader.getAttributeCount(); i++) { String attributeName = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (attributes.containsKey(attributeName)) { AttributeDefinition def = attributes.get(attributeName); AttributeParser parser = def.getParser(); assert parser != null; parser.parseAndSetParameter(def, value, op, reader); } else if (Arrays.binarySearch(additionalExpectedAttributes, attributeName) < 0) { throw ParseUtils.unexpectedAttribute(reader, i, attributes.keySet()); } } if (!attributeElements.isEmpty()) { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { String attrName = reader.getLocalName(); if (attributeElements.containsKey(attrName)) { AttributeDefinition ad = attributeElements.get(reader.getLocalName()); ad.getParser().parseElement(ad, reader, op); } else { throw ParseUtils.unexpectedElement(reader, attributeElements.keySet()); } } } }</code><technical_language>This technically i18n, overhead of defeats purpose of this PR. duplicate check removed. a side effect of Collectors.toMap kind of check is responsibility of this method. save more code. ;)</technical_language>

Target:
static void parseEmbeddedElement(ObjectTypeAttributeDefinition attribute, XMLExtendedStreamReader reader, ModelNode op, String... additionalExpectedAttributes) throws XMLStreamException { AttributeDefinition[] valueTypes = attribute.getValueTypes(); Map<String, AttributeDefinition> attributes = new HashMap<>(); for (AttributeDefinition valueType : valueTypes) { attributes.put(valueType.getXmlName(), valueType); } Map<String, AttributeDefinition> attributeElements = new HashMap<>(); for (AttributeDefinition attributeDefinition : valueTypes) { if (attributeDefinition.getParser().isParseAsElement()) { attributeElements.put(attributeDefinition.getParser().getXmlName(attributeDefinition), attributeDefinition); } } for (int i = 0; i < reader.getAttributeCount(); i++) { String attributeName = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (attributes.containsKey(attributeName)) { AttributeDefinition def = attributes.get(attributeName); AttributeParser parser = def.getParser(); assert parser != null; parser.parseAndSetParameter(def, value, op, reader); } else if (Arrays.binarySearch(additionalExpectedAttributes, attributeName) < 0) { throw ParseUtils.unexpectedAttribute(reader, i, attributes.keySet()); } } if (!attributeElements.isEmpty()) { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { String attrName = reader.getLocalName(); if (attributeElements.containsKey(attrName)) { AttributeDefinition ad = attributeElements.get(reader.getLocalName()); ad.getParser().parseElement(ad, reader, op); } else { throw ParseUtils.unexpectedElement(reader, attributeElements.keySet()); } } } }