你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

TargetingFilter Class

  • java.lang.Object
    • com.azure.spring.cloud.feature.management.filters.TargetingFilter

Implements

public class TargetingFilter
implements FeatureFilter

`Microsoft.TargetingFilter` enables evaluating a user/group/overall rollout of a feature.

Field Summary

Modifier and Type Field and Description
protected static final String AUDIENCE

Audience in the filter

protected static final String EXCLUSION

Audience that always returns false

protected static final String GROUPS

groups field in the filter

protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER

Object Mapper for converting configurations to features

protected static final String OUT_OF_RANGE

Error message for when the total Audience value is greater than 100 percent.

protected static final String USERS

users field in the filter

protected final TargetingContextAccessor contextAccessor

Accessor for identifying the current user/group when evaluating

protected final TargetingEvaluationOptions options

Options for evaluating the filter

Constructor Summary

Constructor Description
TargetingFilter(TargetingContextAccessor contextAccessor)

Filter for targeting a user/group/percentage of users.

TargetingFilter(TargetingContextAccessor contextAccessor, TargetingEvaluationOptions options)

`Microsoft.TargetingFilter` evaluates a user/group/overall rollout of a feature.

Method Summary

Modifier and Type Method and Description
boolean evaluate(FeatureFilterEvaluationContext context)

Evaluates if the filter is on or off.

protected double isTargetedPercentage(String contextId)

Computes the percentage that the contextId falls into.

Methods inherited from java.lang.Object

Field Details

AUDIENCE

protected static final String AUDIENCE

Audience in the filter

EXCLUSION

protected static final String EXCLUSION

Audience that always returns false

GROUPS

protected static final String GROUPS

groups field in the filter

OBJECT_MAPPER

protected static final ObjectMapper OBJECT_MAPPER

Object Mapper for converting configurations to features

OUT_OF_RANGE

protected static final String OUT_OF_RANGE

Error message for when the total Audience value is greater than 100 percent.

USERS

protected static final String USERS

users field in the filter

contextAccessor

protected final TargetingContextAccessor contextAccessor

Accessor for identifying the current user/group when evaluating

options

protected final TargetingEvaluationOptions options

Options for evaluating the filter

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)

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.

Parameters:

context

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

Applies to