public abstract class Attribute<CoercedType> extends Object implements AttributeHolder
| Constructor and Description |
|---|
Attribute() |
| Modifier and Type | Method and Description |
|---|---|
Attribute<?> |
getAttribute()
Get the actual attribute object
|
abstract String |
getDoc()
The docstring to use for this attribute
|
Type |
getGenericType()
Get the generic type of
CoercedType. |
abstract boolean |
getMandatory()
Whether this attribute is mandatory or not
|
PostCoercionTransform<RuleAnalysisContext,?> |
getPostCoercionTransform() |
abstract Object |
getPreCoercionDefaultValue()
The default value to use if no value is provided.
|
abstract TypeCoercer<?,CoercedType> |
getTypeCoercer()
The type coercer to use to convert raw values from the parser into something usable internally.
|
CoercedType |
getValue(CellNameResolver cellNameResolver,
ProjectFilesystem projectFilesystem,
ForwardRelativePath pathRelativeToProjectRoot,
TargetConfiguration targetConfiguration,
TargetConfiguration hostConfiguration,
Object value)
Get the coerced value for this attribute.
|
protected void |
validateCoercedValue(CoercedType value)
Validates values post-coercion to ensure other properties besides 'type' are valid
|
protected static void |
validateProvidersPresent(List<Provider<?>> expectedProviders,
BuildTarget target,
ProviderInfoCollection providerInfos)
|
protected void |
validateValueInList(List<CoercedType> values,
CoercedType value)
Helper method to validate that a value is in a list and throw a reasonable error if not
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic Attribute<?> getAttribute()
AttributeHoldergetAttribute in interface AttributeHolder@Value.Lazy public Type getGenericType()
CoercedType.public abstract Object getPreCoercionDefaultValue()
This will be validated against getTypeCoercer(), so may return a value whose type
does not match CoercedType (e.g. a list of strings, rather than a list of SourcePath)
public abstract String getDoc()
public abstract boolean getMandatory()
public abstract TypeCoercer<?,CoercedType> getTypeCoercer()
protected void validateCoercedValue(CoercedType value) throws CoerceFailedException
value - The value to checkCoerceFailedException - if the value is invalid (e.g. not in a list of pre-approved
values)public PostCoercionTransform<RuleAnalysisContext,?> getPostCoercionTransform()
public CoercedType getValue(CellNameResolver cellNameResolver, ProjectFilesystem projectFilesystem, ForwardRelativePath pathRelativeToProjectRoot, TargetConfiguration targetConfiguration, TargetConfiguration hostConfiguration, Object value) throws CoerceFailedException
cellNameResolver - The cell rootsprojectFilesystem - The project file systempathRelativeToProjectRoot - The path relative to the project roottargetConfiguration - The configuration for this targethostConfiguration - value - The object that is to be coerced. This generally comes directly from the parser.CoerceFailedException - if the value could not be coercedprotected void validateValueInList(List<CoercedType> values, CoercedType value) throws CoerceFailedException
CoerceFailedExceptionprotected static void validateProvidersPresent(List<Provider<?>> expectedProviders, BuildTarget target, ProviderInfoCollection providerInfos)
Providers in expectedProviders are present in providerInfos
Note that it is enforced that all build rules return at least DefaultInfo, so that is not required to be
specified
expectedProviders - The providers that ALL MUST be present. If empty, no providers are
required, and all providerInfos will be considered valid.target - the target that providerInfos is associated with. Used in errors.providerInfos - The ProviderInfos for a given dependencycom.google.common.base.VerifyException - if a provider is missing in providerInfos