Package org.gradle.api.attributes

# Interface AttributesSchema

public interface AttributesSchema
An attributes schema stores information about `attributes` and how they can be matched together.

Since:
  3.3

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> AttributeMatchingStrategy<T>`
  `attribute(Attribute<T> attribute)`
  Declares a new attribute in the schema and configures it with the default strategy.
  `<T> AttributeMatchingStrategy<T>`
  `attribute(Attribute<T> attribute, Action<? super AttributeMatchingStrategy<T>> configureAction)`
  Configures the matching strategy for an attribute.
  `void`
  `attributeDisambiguationPrecedence(Attribute<?>... attributes)`
  Adds attributes to the precedence order.
  `List<Attribute<?>>`
  `getAttributeDisambiguationPrecedence()`
  Returns the order that attributes should be considered when resolving ambiguity.
  `Set<Attribute<?>>`
  `getAttributes()`
  Returns the set of attributes known to this schema.
  `<T> AttributeMatchingStrategy<T>`
  `getMatchingStrategy(Attribute<T> attribute)`
  Returns the matching strategy for a given attribute.
  `boolean`
  `hasAttribute(Attribute<?> key)`
  Returns true when this schema contains the given attribute.
  `void`
  `setAttributeDisambiguationPrecedence(List<Attribute<?>> attributes)`
  Sets the order of precedence of attributes when resolving ambiguity.

- ## Method Details

  - ### getMatchingStrategy

    <T> AttributeMatchingStrategy<T> getMatchingStrategy(Attribute<T> attribute) throws IllegalArgumentException
    Returns the matching strategy for a given attribute.
    Type Parameters:
      `T` - the type of the attribute
    Parameters:
      `attribute` - the attribute
    Returns:
      the matching strategy for this attribute.
    Throws:
      `IllegalArgumentException` - When no strategy is available for the given attribute.

  - ### attribute

    <T> AttributeMatchingStrategy<T> attribute(Attribute<T> attribute)
    Declares a new attribute in the schema and configures it with the default strategy. If the attribute was already declared it will simply return the existing strategy.
    Type Parameters:
      `T` - the concrete type of the attribute
    Parameters:
      `attribute` - the attribute to declare in the schema
    Returns:
      the matching strategy for this attribute

  - ### attribute

    <T> AttributeMatchingStrategy<T> attribute(Attribute<T> attribute, Action<? super AttributeMatchingStrategy<T>> configureAction)
    Configures the matching strategy for an attribute. The first call to this method for a specific attribute will create a new matching strategy, whereas subsequent calls will configure the existing one.
    Type Parameters:
      `T` - the concrete type of the attribute
    Parameters:
      `attribute` - the attribute for which to configure the matching strategy
      `configureAction` - the strategy configuration
    Returns:
      the configured strategy

  - ### getAttributes

    Set<Attribute<?>> getAttributes()
    Returns the set of attributes known to this schema.

  - ### hasAttribute

    boolean hasAttribute(Attribute<?> key)
    Returns true when this schema contains the given attribute.

  - ### attributeDisambiguationPrecedence

    @Incubating void attributeDisambiguationPrecedence(Attribute<?>... attributes)
    Adds attributes to the precedence order. Attributes listed first have higher precedence.

    The attributes will be added to any existing precedence order. If an attribute has already been added, adding it again will fail.

    Parameters:
      `attributes` - the attributes in order
    Since:
      7.5
    See Also:
      - `setAttributeDisambiguationPrecedence(List)`

  - ### setAttributeDisambiguationPrecedence

    @Incubating void setAttributeDisambiguationPrecedence(List<Attribute<?>> attributes)
    Sets the order of precedence of attributes when resolving ambiguity. Attributes listed first have higher precedence.

    By default, there is no explicit precedence between attributes and all attributes must be considered when disambiguating.

    Parameters:
      `attributes` - the attributes in order, highest priority first
    Since:
      7.5

  - ### getAttributeDisambiguationPrecedence

    @Incubating List<Attribute<?>> getAttributeDisambiguationPrecedence()
    Returns the order that attributes should be considered when resolving ambiguity.
    Returns:
      an immutable list of the attributes in precedence order, with the highest priority first
    Since:
      7.5