api / org.gradle.api.attributes / Attribute / of

of

open static fun <T : Any> of(name: String, type: Class<T>): Attribute<T>

Creates a new attribute of the given name with the given type. There's no guarantee that subsequent calls to this method with the same attributes would either return the same instance or different instances of Attribute, so consumers are required to compare the attributes with the #equals(Object) method.

Parameters

name - the name of the attribute

type - the class of the attribute

- the type of the attribute

Return
an attribute with the given name and type

open static fun <T : Any> of(type: Class<T>): Attribute<T>

Creates a new attribute of the given type, inferring the name of the attribute from the simple type name. This method is useful when there's supposely only one attribute of a specific type in a container, so there's no need to distinguish by name (but the returned type doesn't enforce it_. There's no guarantee that subsequent calls to this method with the same attributes would either return the same instance or different instances of Attribute, so consumers are required to compare the attributes with the #equals(Object) method.

Parameters

type - the class of the attribute

- the type of the attribute

Return
an attribute with the given name and type