RULE_KEY
- - the actual type that the builder produces (e.g. HashCode
).public abstract class RuleKeyBuilder<RULE_KEY> extends AbstractRuleKeyBuilder<RULE_KEY>
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.
Constructor and Description |
---|
RuleKeyBuilder(SourcePathRuleFinder ruleFinder,
FileHashLoader hashLoader,
CountingRuleKeyHasher<RULE_KEY> hasher) |
RuleKeyBuilder(SourcePathRuleFinder ruleFinder,
FileHashLoader hashLoader,
RuleKeyHasher<RULE_KEY> hasher) |
Modifier and Type | Method and Description |
---|---|
RULE_KEY |
build()
Builds the rule key hash.
|
RuleKeyBuilder<RULE_KEY> |
setPath(Path absolutePath,
Path ideallyRelative) |
protected RuleKeyBuilder<RULE_KEY> |
setPath(ProjectFilesystem filesystem,
Path relativePath) |
protected RuleKeyBuilder<RULE_KEY> |
setSingleValue(Object val) |
build, setAction, setAddsToRuleKey, setBuildRule, setNonHashingSourcePath, setReflectively, setReflectively, setReflectivelyPathKey, setSourcePath
public RuleKeyBuilder(SourcePathRuleFinder ruleFinder, FileHashLoader hashLoader, CountingRuleKeyHasher<RULE_KEY> hasher)
public RuleKeyBuilder(SourcePathRuleFinder ruleFinder, FileHashLoader hashLoader, RuleKeyHasher<RULE_KEY> hasher)
public RuleKeyBuilder<RULE_KEY> setPath(Path absolutePath, Path ideallyRelative) throws IOException
IOException
protected RuleKeyBuilder<RULE_KEY> setPath(ProjectFilesystem filesystem, Path relativePath) throws IOException
IOException
protected final RuleKeyBuilder<RULE_KEY> setSingleValue(@Nullable Object val)
setSingleValue
in class AbstractRuleKeyBuilder<RULE_KEY>
public final RULE_KEY build()
build
in class AbstractRuleKeyBuilder<RULE_KEY>