Class TargetingFilter

java.lang.Object
com.azure.spring.cloud.feature.management.filters.TargetingFilter
All Implemented Interfaces:
FeatureFilter

public class TargetingFilter extends Object implements FeatureFilter
`Microsoft.TargetingFilter` enables evaluating a user/group/overall rollout of a feature.
  • Field Details

  • Constructor Details

    • TargetingFilter

      public TargetingFilter(TargetingContextAccessor contextAccessor)
      Filter for targeting a user/group/percentage of users.
      Parameters:
      contextAccessor - Accessor for identifying the current user/group when evaluating
    • TargetingFilter

      public TargetingFilter(TargetingContextAccessor contextAccessor, TargetingEvaluationOptions options)
      `Microsoft.TargetingFilter` evaluates a user/group/overall rollout of a feature.
      Parameters:
      contextAccessor - Context for evaluating the users/groups.
      options - enables customization of the filter.
  • Method Details

    • evaluate

      public boolean evaluate(FeatureFilterEvaluationContext context)
      Description copied from interface: FeatureFilter
      Evaluates if the filter is on or off. Returning true results in Feature evaluation ending and returning true. Returning false results in the next Feature evaluation to continue.
      Specified by:
      evaluate in interface FeatureFilter
      Parameters:
      context - The context for whether or not the filter is passed.
      Returns:
      True if the feature is enabled, false otherwise.
    • isTargetedPercentage

      protected double isTargetedPercentage(String contextId)
      Computes the percentage that the contextId falls into.
      Parameters:
      contextId - Id of the context being targeted
      Returns:
      the bucket value of the context id
      Throws:
      TargetingException - Unable to create hash of target context