import JDLObject from './jdl-object.js';
export default function mergeJDLObjects(firstJDLObject, secondJDLObject) {
    if (!firstJDLObject || !secondJDLObject) {
        throw new Error("Can't merge nil JDL objects.");
    }
    const merged = new JDLObject();
    const addApplication = application => merged.addApplication(application);
    const addEntity = entity => merged.addEntity(entity);
    const addEnumeration = enumeration => merged.addEnum(enumeration);
    const addRelationship = relationship => merged.addRelationship(relationship);
    const addAigc = aigc => merged.addAigc(aigc);
    const addOption = option => merged.addOption(option);
    firstJDLObject.forEachApplication(addApplication);
    secondJDLObject.forEachApplication(addApplication);
    firstJDLObject.forEachEntity(addEntity);
    secondJDLObject.forEachEntity(addEntity);
    firstJDLObject.forEachEnum(addEnumeration);
    secondJDLObject.forEachEnum(addEnumeration);
    firstJDLObject.forEachRelationship(addRelationship);
    secondJDLObject.forEachRelationship(addRelationship);
    firstJDLObject.forEachAigc(addAigc);
    secondJDLObject.forEachAigc(addAigc);
    firstJDLObject.forEachOption(addOption);
    secondJDLObject.forEachOption(addOption);
    return merged;
}
