Package org.gradle.api.provider

# Interface SetProperty<T>

Type Parameters:
  `T` - the type of elements.

All Superinterfaces:
  `HasConfigurableValue`, `HasMultipleValues<T>`, `Provider<Set<T>>`, `SupportsConvention`

public interface SetProperty<T> extends Provider<Set<T>>, HasMultipleValues<T>
Represents a property whose type is a `Set` of elements of type `SetProperty`. Retains iteration order.

You can create a `SetProperty` instance using factory method `ObjectFactory.setProperty(Class)`.

Instances of this interface are not thread-safe for reading and writing. It is not safe to share the same SetProperty instance between different projects.

Note: This interface is not intended for implementation by build script or plugin authors.

Since:
  4.5

- ## Method Summary

  Modifier and Type
  Method
  Description
  `SetProperty<T>`
  `convention(Iterable<? extends T> elements)`
  Specifies the value to use as the convention for this property.
  `SetProperty<T>`
  `convention(Provider<? extends Iterable<? extends T>> provider)`
  Specifies the provider of the value to use as the convention for this property.
  `SetProperty<T>`
  `empty()`
  Sets the value of this property to an empty collection, and replaces any existing value.
  `SetProperty<T>`
  `unset()`
  Unsets this object's explicit value, allowing the convention to be selected when evaluating this object's value.
  `SetProperty<T>`
  `unsetConvention()`
  Unsets this object's convention value.
  `SetProperty<T>`
  `value(Iterable<? extends T> elements)`
  Sets the value of the property to the elements of the given iterable, and replaces any existing value.
  `SetProperty<T>`
  `value(Provider<? extends Iterable<? extends T>> provider)`
  Sets the property to have the same value of the given provider, and replaces any existing value.

  ### Methods inherited from interface org.gradle.api.provider.HasConfigurableValue

  `disallowChanges, disallowUnsafeRead, finalizeValueOnRead`

  ### Methods inherited from interface org.gradle.api.provider.HasMultipleValues

  `add, add, addAll, addAll, addAll, finalizeValue, set, set`

  ### Methods inherited from interface org.gradle.api.provider.Provider

  `filter, flatMap, forUseAtConfigurationTime, get, getOrElse, getOrNull, isPresent, map, orElse, orElse, zip`

- ## Method Details

  - ### empty

    SetProperty<T> empty()
    Sets the value of this property to an empty collection, and replaces any existing value.
    Specified by:
      `empty` in interface `HasMultipleValues<T>`
    Returns:
      this property.

  - ### value

    SetProperty<T> value(@Nullable Iterable<? extends T> elements)
    Sets the value of the property to the elements of the given iterable, and replaces any existing value. This property will query the elements of the iterable each time the value of this property is queried.

    This is the same as `HasMultipleValues.set(Iterable)` but returns this property to allow method chaining.

    Specified by:
      `value` in interface `HasMultipleValues<T>`
    Parameters:
      `elements` - The elements, can be null.
    Returns:
      this

  - ### value

    SetProperty<T> value(Provider<? extends Iterable<? extends T>> provider)
    Sets the property to have the same value of the given provider, and replaces any existing value. This property will track the value of the provider and query its value each time the value of this property is queried. When the provider has no value, this property will also have no value.

    This is the same as `HasMultipleValues.set(Provider)` but returns this property to allow method chaining.

    Specified by:
      `value` in interface `HasMultipleValues<T>`
    Parameters:
      `provider` - Provider of the elements.
    Returns:
      this

  - ### convention

    SetProperty<T> convention(@Nullable Iterable<? extends T> elements)
    Specifies the value to use as the convention for this property. The convention is used when no value has been set for this property.
    Specified by:
      `convention` in interface `HasMultipleValues<T>`
    Parameters:
      `elements` - The elements, or `null` when the convention is that the property has no value.
    Returns:
      this

  - ### convention

    SetProperty<T> convention(Provider<? extends Iterable<? extends T>> provider)
    Specifies the provider of the value to use as the convention for this property. The convention is used when no value has been set for this property.
    Specified by:
      `convention` in interface `HasMultipleValues<T>`
    Parameters:
      `provider` - The provider of the elements
    Returns:
      this

  - ### unset

    SetProperty<T> unset()
    Unsets this object's explicit value, allowing the convention to be selected when evaluating this object's value.

    This is similar to calling `value(Iterable)` with a `null` argument.

    Specified by:
      `unset` in interface `SupportsConvention`

  - ### unsetConvention

    SetProperty<T> unsetConvention()
    Unsets this object's convention value.

    This is similar to calling `convention(Iterable)` with a `null` argument.

    Specified by:
      `unsetConvention` in interface `SupportsConvention`