function aggregateDescription(this, srcCvd1, srcCvd2)
%CVDATA  Coverage data aggregate description

%   Copyright 2015-2018 The MathWorks, Inc.


this.description = joinProp(srcCvd1.description, srcCvd2.description);
this.tag = joinProp(srcCvd1.tag, srcCvd2.tag);

cvdata.aggregateUniqueIds(this, srcCvd1, srcCvd2);
if isfield(srcCvd1, 'ownerModel')
    this.ownerModel = aggreateProp(srcCvd1.ownerModel, srcCvd2.ownerModel);
    this.harnessModel = aggreateProp(srcCvd1.harnessModel, srcCvd2.harnessModel);
end

%=================
function res = joinProp(prop1, prop2)
    res = prop1;
    
    if contains(prop1, prop2)
        prop2 = '';
    elseif contains(prop2, prop1)
        prop1 = '';
    end

    if ~isempty(prop1) && ~isempty(prop2)
        res = [prop1 ', ' prop2];
    elseif ~isempty(prop1) 
        res = prop1;
    elseif ~isempty(prop2) 
        res = prop2;
    end

%=================
function res = aggreateProp(prop1, prop2)
if ~strcmpi(prop1, prop2)
    res = joinProp(prop1, prop2);
else
    res = prop1;
end


