function NewXTable = applyConditionalVariableFcn(this, XTable)
%

%   Copyright 2016-2022 The MathWorks, Inc.

NewXTable = XTable;
if ~isempty(this.PrivOptions.ConditionalVariableFcn)
    try
        NewXTable = this.PrivOptions.ConditionalVariableFcn(XTable);
    catch me
        bayesoptim.warn('ConditionalVariableFcnError');
        rethrow(me);
    end
    % Check output
    if ~(istable(NewXTable) && ...
            isequal(size(NewXTable), size(XTable)) && ...
            isequal(varfun(@class, NewXTable, 'OutputFormat','cell'), varfun(@class, XTable, 'OutputFormat','cell')) && ...
            isequal(NewXTable.Properties.VariableNames, XTable.Properties.VariableNames))
        bayesoptim.err('ConditionalVariableFcnOutput');
    end
end
end
