Class RuleKeyBuilder<RULE_KEY>
- java.lang.Object
-
- com.facebook.buck.rules.keys.AbstractRuleKeyBuilder<RULE_KEY>
-
- com.facebook.buck.rules.keys.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 implementAbstractRuleKeyBuilder.setAddsToRuleKey(AddsToRuleKey)
, andAbstractRuleKeyBuilder.setBuildRule(BuildRule)
.This class implements
AbstractRuleKeyBuilder
interface which is the primary mechanism of howRuleKeyFactory
andAddsToRuleKey
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 Summary
Constructors Constructor Description RuleKeyBuilder(SourcePathRuleFinder ruleFinder, FileHashLoader hashLoader, CountingRuleKeyHasher<RULE_KEY> hasher)
RuleKeyBuilder(SourcePathRuleFinder ruleFinder, FileHashLoader hashLoader, RuleKeyHasher<RULE_KEY> hasher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RULE_KEY
build()
Builds the rule key hash.protected RuleKeyBuilder<RULE_KEY>
setPath(ProjectFilesystem filesystem, Path relativePath)
RuleKeyBuilder<RULE_KEY>
setPath(Path absolutePath, Path ideallyRelative)
protected RuleKeyBuilder<RULE_KEY>
setSingleValue(Object val)
-
Methods inherited from class com.facebook.buck.rules.keys.AbstractRuleKeyBuilder
build, setAction, setAddsToRuleKey, setBuildRule, setNonHashingSourcePath, setReflectively, setReflectively, setReflectivelyPathKey, setSourcePath
-
-
-
-
Constructor Detail
-
RuleKeyBuilder
public RuleKeyBuilder(SourcePathRuleFinder ruleFinder, FileHashLoader hashLoader, CountingRuleKeyHasher<RULE_KEY> hasher)
-
RuleKeyBuilder
public RuleKeyBuilder(SourcePathRuleFinder ruleFinder, FileHashLoader hashLoader, RuleKeyHasher<RULE_KEY> hasher)
-
-
Method Detail
-
setPath
public RuleKeyBuilder<RULE_KEY> setPath(Path absolutePath, Path ideallyRelative) throws IOException
- Throws:
IOException
-
setPath
protected RuleKeyBuilder<RULE_KEY> setPath(ProjectFilesystem filesystem, Path relativePath) throws IOException
- Throws:
IOException
-
setSingleValue
protected final RuleKeyBuilder<RULE_KEY> setSingleValue(@Nullable Object val)
- Specified by:
setSingleValue
in classAbstractRuleKeyBuilder<RULE_KEY>
-
build
public final RULE_KEY build()
Builds the rule key hash.- Specified by:
build
in classAbstractRuleKeyBuilder<RULE_KEY>
-
-