classdef DerivedProtectedStrategy < fxptds.RangeAggregation.SimpleExtractionStrategy
    %% DERIVEDPROTECTEDSTRATEGY class
    % This class extracts derived ranges for a group. If the derived ranges
    % for the group are infinite, the ranges are discarded. 
    
    % Copyright 2018-2021 The MathWorks, Inc.
    
    methods
        function this = DerivedProtectedStrategy(varargin)
            p = inputParser();
            p.KeepUnmatched = true;
            p.addParameter('RangeType', fxptds.RangeType.Derived);
            p.parse(varargin{:});
            rangeType = p.Results.RangeType;
            % call the constructor of the parent class
            this@fxptds.RangeAggregation.SimpleExtractionStrategy(rangeType);
        end
        
        function range = extractRange(this, group)
            % get the ranges from simple extraction
            range = extractRange@fxptds.RangeAggregation.SimpleExtractionStrategy(this, group);
            
            % if any range is infinite, discard and return empty
            if any(isinf(range))
                range = [];
            end
        end
    end
end

