api / org.gradle.api.attributes / AttributeContainer

AttributeContainer

@Incubating interface AttributeContainer : HasAttributes

An attribute container is a container of Attribute, which are strongly typed named entities. Such a container is responsible for storing and getting attributes in a type safe way. In particular, attributes are strongly typed, meaning that when we get a value from the container, the returned value type is inferred from the type of the attribute. In a way, an attribute container is similar to a java.util.Map where the entry is a "typed String" and the value is of the string type. However the set of methods available to the container is much more limited. It is not allowed to have two attributes with the same name but different types in the container.

Since
3.3

Functions

attribute

abstract fun <T : Any> attribute(key: Attribute<T>, value: T): AttributeContainer

Sets an attribute value. It is not allowed to use null as an attribute value.

contains

abstract fun contains(key: Attribute<*>): Boolean

Tells if a specific attribute is found in this container.

getAttribute

abstract fun <T : Any> getAttribute(key: Attribute<T>): T

Returns the value of an attribute found in this container, or null if this container doesn't have it.

isEmpty

abstract fun isEmpty(): Boolean

Returns true if this container is empty.

keySet

abstract fun keySet(): MutableSet<Attribute<*>>

Returns the set of attribute keys of this container.

Inherited Functions

getAttributes

abstract fun getAttributes(): AttributeContainer

Returns the attributes