private void processOCDAttributes(String currDefId, AttributeDefinition[] attrDefs, Map<String, AttributeDefinition> requiredAttributes,
                                      Map<String, AttributeDefinition> optionalAttributes, Map<String, ExtendedAttributeDefinition> attributeMap,
                                      boolean required) {

        // We need to set the current Attributes Map to be the optional list if we're processing option attrs, or required otherwise. We set the
        // alternativeAttributes to be the other Map of attrs.
        Map<String, AttributeDefinition> currentAttributes;
        Map<String, AttributeDefinition> alternateAttributes;

        if (required) {
            currentAttributes = requiredAttributes;
            alternateAttributes = optionalAttributes;
        } else {
            currentAttributes = optionalAttributes;
            alternateAttributes = requiredAttributes;
        }

        // Iterate over the list of attributes
        for (AttributeDefinition attrDef : attrDefs) {

            String attrId = attrDef.getID();
            ExtendedAttributeDefinition extendedAttr = attributeMap.get(attrId);
            String rename;
            if (extendedAttr != null) {
                // If we have a final attr, we don't add it to the list of attrs to write out, and we should also
                // remove it from the existing list if it was defined in a super type.
                if (extendedAttr.isFinal()) {
                    currentAttributes.remove(attrId);
                    alternateAttributes.remove(attrId);

                } else if ((rename = extendedAttr.getRename()) != null) {
                    // If  we have a rename, then we should take the existing attr, and replace any values that are defined in
                    // in the new attr.
                    boolean alternativeAttr = false;
                    AttributeDefinition attrToRename = currentAttributes.get(rename);
                    // if the attribute to rename is null, then it might be because it has been defined as an optional and is now a required attr,
                    // or visa versa. Before we complain that the attr doesn't exist, check the other list of attrs to see if that is the case.
                    // If so, remove the attr from whichever Map it has been defined in, and add it to the current Attribute Map.
                    // e.g. if we have an renamed attr that is not optional, it may have been defined as required in the super definition.
                    //      if so remove from required attr Map and add to the optional attr Map.
                    if (attrToRename == null) {
                        attrToRename = alternateAttributes.get(rename);
                        alternativeAttr = true;
                    }
                    // If we still haven't found the attr that we're renaming, issue a warning msg, and stop processing this Definition.
                    // Otherwise build up a new attribute based which is a "merge" of new values, and any old values that haven't been defined
                    // in the rename attribute. We add this new one, and remove the original from whichever Map of attributes it was previous
                    // defined in.
                    if (attrToRename == null) {
                        // If we can't find the attribute that we're trying to rename then issue a warning.
                        error("schemagen.rename.attribute.missing", new Object[] { currDefId, rename, extendedAttr.getID() });
                    } else {
                        // Add the new attr to the current list, and remove the old version from the optional or required depending on where it was
                        // defined.
                        currentAttributes.put(attrId, renameAttribute(currDefId, attributeMap.get(rename), extendedAttr, required));
                        if (alternativeAttr)
                            alternateAttributes.remove(rename);
                        else
                            currentAttributes.remove(rename);
                    }
                    // Otherwise we've got no extensions so just add the attribute to the list.
                } else {
                    currentAttributes.put(attrId, attrDef);
                }
            }
        }
    }
private void processOCDAttributes ( String currDefId , AttributeDefinition [ ] attrDefs , Map < String , AttributeDefinition > requiredAttributes , Map < String , AttributeDefinition > optionalAttributes , Map < String , ExtendedAttributeDefinition > attributeMap , boolean required ) { Map < String , AttributeDefinition > currentAttributes ; Map < String , AttributeDefinition > alternateAttributes ; if ( required ) { currentAttributes = requiredAttributes ; alternateAttributes = optionalAttributes ; } else { currentAttributes = optionalAttributes ; alternateAttributes = requiredAttributes ; } for ( AttributeDefinition attrDef : attrDefs ) { String attrId = attrDef . getID ( ) ; ExtendedAttributeDefinition extendedAttr = attributeMap . get ( attrId ) ; String rename ; if ( extendedAttr != null ) { if ( extendedAttr . isFinal ( ) ) { currentAttributes . remove ( attrId ) ; alternateAttributes . remove ( attrId ) ; } else if ( ( rename = extendedAttr . getRename ( ) ) != null ) { boolean alternativeAttr = false ; AttributeDefinition attrToRename = currentAttributes . get ( rename ) ; if ( attrToRename == null ) { attrToRename = alternateAttributes . get ( rename ) ; alternativeAttr = true ; } if ( attrToRename == null ) { error ( "schemagen.rename.attribute.missing" , new Object [ ] { currDefId , rename , extendedAttr . getID ( ) } ) ; } else { currentAttributes . put ( attrId , renameAttribute ( currDefId , attributeMap . get ( rename ) , extendedAttr , required ) ) ; if ( alternativeAttr ) alternateAttributes . remove ( rename ) ; else currentAttributes . remove ( rename ) ; } } else { currentAttributes . put ( attrId , attrDef ) ; } } } }
This method takes a set of Attribute Definitions and processes them against an existing Map of attributes.

@param currDefId - A String containing the id of the ObjectClassDefinition that we're processing.
@param attrDefs - The Attribute Definitions of the ObjectClassDefinition that we're processing
@param currentAttributes - The existing map of properties from previous ObjectClassDefinition's in the heirarchy.
@param requiredAttributes - The current list of required Attributes from the processed definitions.
@param optionalAttributes - The current list of optional Attributes from the processed definitions.
@param attributeMap - The list of ExtendedDefinitionAttributes for all of the OCD's in the heirarchy.
@param required - A boolean indicating whether the list of currentAttributes are required or optional.