Skip to content

UTIL_FeatureFlag.INT_FeatureFlagStrategy

Class

apex
global interface UTIL_FeatureFlag.INT_FeatureFlagStrategy

Known Derived Types: UTIL_FeatureFlag.INT_UserAwareFeatureFlagStrategy

The global interface for all feature evaluation strategies. Implement this interface and reference your class from FeatureFlagStrategy__mdt.CustomHandler__c to replace any built-in strategy. This is the recommended escape hatch when the built-in Hierarchical/List Custom Setting or Custom Metadata strategies cause SOQL hot spots: a custom handler can call typed MyCS__c.getInstance(userId) / MyType__mdt.getInstance(name) directly for zero-SOQL platform-cached reads. See the Utilities Guide → "Performance and SOQL Cost".

Since: 1.0

Example:

apex
// Example implementation of a custom strategy
public class MY_Region_Strategy implements UTIL_FeatureFlag.INT_FeatureFlagStrategy
{
    public Boolean isEnabled(FeatureFlag__mdt flag, FeatureFlagStrategy__mdt strategyToEvaluate)
    {
        // Custom logic to enable feature only for users in the 'US'
        Boolean isFeatureEnabled = UserInfo.getCountry() == 'US';
        return isFeatureEnabled;
    }
}

Methods

MethodDescription
global abstract Boolean isEnabled(FeatureFlag__mdt flag, FeatureFlagStrategy__mdt strategyToEvaluate)Evaluates the strategy and determines if the feature should be enabled.

Method Details

isEnabled

apex
global abstract Boolean isEnabled(FeatureFlag__mdt flag, FeatureFlagStrategy__mdt strategyToEvaluate)

Evaluates the strategy and determines if the feature should be enabled.

Parameters:

Returns: Boolean - true if the feature is enabled by this strategy, false otherwise.

Since: 1.0

Example:

apex
public Boolean isEnabled(FeatureFlag__mdt flag, FeatureFlagStrategy__mdt strategyToEvaluate)
{
    // Check if the strategy's target value matches our condition
    Boolean isTargetMet = strategyToEvaluate.TargetValue__c == 'Some_Value';
    return isTargetMet;
}