Class RuleKeyBuilder<RULE_KEY>

  • Type Parameters:
    RULE_KEY - - the actual type that the builder produces (e.g. HashCode).
    Direct Known Subclasses:
    ContentAgnosticRuleKeyFactory.Builder, DefaultRuleKeyFactory.Builder

    public abstract class RuleKeyBuilder<RULE_KEY>
    extends AbstractRuleKeyBuilder<RULE_KEY>
    A base implementation for rule key builders.

    RuleKeyFactory classes create concrete instances of this class and use them to produce rule keys. Concrete implementations may tweak behavior of the builder, and at the very minimum should implement AbstractRuleKeyBuilder.setAddsToRuleKey(AddsToRuleKey), and AbstractRuleKeyBuilder.setBuildRule(BuildRule).

    This class implements AbstractRuleKeyBuilder interface which is the primary mechanism of how RuleKeyFactory and AddsToRuleKey classes feed the builder.

    Each element fed to the builder is a (key, value) pair. Keys are always simple strings, typically the name of a field annotated with AddToRuleKey. Values on the other hand may be complex types that are resolved recursively. For instance, a list of elements gets serialized by serializing each element of the list in order, and finally serializing the list token along with the length of the list. Similarly for other containers and wrappers.

    There is an exception to the above rule of how containers and wrappers get serialized. Namely, they only get serialized if at least one of their elements gets serialized. This is to support concrete rule key builders that ignore some elements, or handle them differently. For example, several concrete builders handle SourcePath elements in a special way.