Package org.gradle.api.provider

## Interface Property<T>

- Type Parameters:
    `T` - Type of value represented by the property
  All Superinterfaces:
    `HasConfigurableValue`, `Provider<T>`
  All Known Subinterfaces:
    `DirectoryProperty`, `FileSystemLocationProperty<T>`, `RegularFileProperty`

      public interface Property<T>
      extends Provider<T>, HasConfigurableValue

  A container object that represents a configurable value of a specific type. A `Property` is also a `Provider` and can be used in the same way as a `Provider`. A property's value can be accessed using the methods of `Provider` such as `Provider.get()`. The value can be modified by using the method `set(Object)` or `set(Provider)`.

  A property may be used to represent a task output. Such a property carries information about which task produces its value. When the property is attached to a task input, this allows Gradle to automatically calculate the dependencies between tasks based on the values they use as inputs and produce as outputs.

  You can create a `Property` instance using `ObjectFactory.property(Class)`. There are also several specialized subtypes of this interface that can be created using various other factory methods.

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

  Since:
    4.3

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Property<T>` | `convention​(Provider<? extends T> valueProvider)` | Specifies the provider of the value to use as the convention for this property.
    `Property<T>` | `convention​(T value)` | Specifies the value to use as the convention for this property.
    `void` | `finalizeValue()` | Disallows further changes to the value of this property.
    `void` | `set​(Provider<? extends T> provider)` | Sets the property to have the same value of the given provider, replacing whatever value the property already had.
    `void` | `set​(T value)` | Sets the value of the property the given value, replacing whatever value the property already had.
    `Property<T>` | `value​(Provider<? extends T> provider)` | Sets the property to have the same value of the given provider, replacing whatever value the property already had.
    `Property<T>` | `value​(T value)` | Sets the value of the property the given value, replacing whatever value the property already had.

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

      `disallowChanges, finalizeValueOnRead`

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

      `flatMap, get, getOrElse, getOrNull, isPresent, map, orElse, orElse`

- - ### Method Detail

    - #### set

          void set​(@Nullable
                   T value)

      Sets the value of the property the given value, replacing whatever value the property already had.

      This method can also be used to discard the value of the property, by passing `null` as the value. The convention for this property, if any, will be used to provide the value instead.

      Parameters:
        `value` - The value, can be null.

    - #### set

          void set​(Provider<? extends T> provider)

      Sets the property to have the same value of the given provider, replacing whatever value the property already had. This property will track the value of the provider and query its value each time the value of the property is queried. When the provider has no value, this property will also have no value.

      When the given provider represents a task output, this property will also carry the task dependency information from the provider.

      Parameters:
        `provider` - The provider whose value to use.

    - #### value

          @Incubating
          Property<T> value​(@Nullable
                            T value)

      Sets the value of the property the given value, replacing whatever value the property already had.

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

      Parameters:
        `value` - The value, can be null.
      Returns:
        this
      Since:
        5.0

    - #### value

          @Incubating
          Property<T> value​(Provider<? extends T> provider)

      Sets the property to have the same value of the given provider, replacing whatever value the property already had. This property will track the value of the provider and query its value each time the value of the property is queried. When the provider has no value, this property will also have no value.

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

      Parameters:
        `provider` - The provider whose value to use.
      Returns:
        this
      Since:
        5.6

    - #### convention

          @Incubating
          Property<T> convention​(T value)

      Specifies the value to use as the convention for this property. The convention is used when no value has been set for this property.
      Parameters:
        `value` - The value.
      Returns:
        this
      Since:
        5.1

    - #### convention

          @Incubating
          Property<T> convention​(Provider<? extends T> valueProvider)

      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.
      Parameters:
        `valueProvider` - The provider of the value.
      Returns:
        this
      Since:
        5.1

    - #### finalizeValue

          @Incubating
          void finalizeValue()

      Disallows further changes to the value of this property. Calls to methods that change the value of this property, such as `set(Object)` or `set(Provider)` will fail.

      When this property has a value provided by a `Provider`, the value of the provider is queried when this method is called and the value of this property set to the result. The value of the provider will no longer be tracked.

      Note that although the value of the property will not change, the value itself may be a mutable object. Calling this method does not guarantee that the value will become immutable.

      Specified by:
        `finalizeValue` in interface `HasConfigurableValue`
      Since:
        5.0