Package org.gradle.api.provider

## Interface ProviderFactory

-     @NonExtensible
      public interface ProviderFactory

  A factory for creating instances of `Provider`.

  An instance of the factory can be injected into a task, plugin or other object by annotating a public constructor or property getter method with `javax.inject.Inject`. It is also available via `Project.getProviders()`.

  Since:
    4.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Provider<String>` | `environmentVariable​(String variableName)` | Creates a `Provider` whose value is fetched from the environment variable with the given name.
    `Provider<String>` | `environmentVariable​(Provider<String> variableName)` | Creates a `Provider` whose value is fetched from the environment variable with the given name.
    `FileContents` | `fileContents​(RegularFile file)` | Allows lazy access to the contents of the given file.
    `FileContents` | `fileContents​(Provider<RegularFile> file)` | Allows lazy access to the contents of the given file.
    `Provider<String>` | `gradleProperty​(String propertyName)` | Creates a `Provider` whose value is fetched from the Gradle property of the given name.
    `Provider<String>` | `gradleProperty​(Provider<String> propertyName)` | Creates a `Provider` whose value is fetched from the Gradle property of the given name.
    `<T,​P extends ValueSourceParameters> Provider<T>` | `of​(Class<? extends ValueSource<T,​P>> valueSourceType, Action<? super ValueSourceSpec<P>> configuration)` | Creates a `Provider` whose value is obtained from the given `ValueSource`.
    `<T> Provider<T>` | `provider​(Callable<? extends T> value)` | Creates a `Provider` whose value is calculated using the given `Callable`.
    `Provider<String>` | `systemProperty​(String propertyName)` | Creates a `Provider` whose value is fetched from system properties using the given property name.
    `Provider<String>` | `systemProperty​(Provider<String> propertyName)` | Creates a `Provider` whose value is fetched from system properties using the given property name.

- - ### Method Detail

    - #### provider

          <T> Provider<T> provider​(Callable<? extends T> value)

      Creates a `Provider` whose value is calculated using the given `Callable`.

      The provider is live and will call the `Callable` each time its value is queried. The `Callable` may return `null`, in which case the provider is considered to have no value.

      Parameters:
        `value` - The `java.util.concurrent.Callable` use to calculate the value.
      Returns:
        The provider. Never returns null.

    - #### environmentVariable

          @Incubating
          Provider<String> environmentVariable​(String variableName)

      Creates a `Provider` whose value is fetched from the environment variable with the given name. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `variableName` - The name of the environment variable.
      Returns:
        The provider. Never returns null.
      Since:
        6.1

    - #### environmentVariable

          @Incubating
          Provider<String> environmentVariable​(Provider<String> variableName)

      Creates a `Provider` whose value is fetched from the environment variable with the given name. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `variableName` - The provider for the name of the environment variable; when the given provider has no value, the returned provider has no value.
      Returns:
        The provider. Never returns null.
      Since:
        6.1

    - #### systemProperty

          @Incubating
          Provider<String> systemProperty​(String propertyName)

      Creates a `Provider` whose value is fetched from system properties using the given property name. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `propertyName` - the name of the system property
      Returns:
        the provider for the system property, never returns null
      Since:
        6.1

    - #### systemProperty

          @Incubating
          Provider<String> systemProperty​(Provider<String> propertyName)

      Creates a `Provider` whose value is fetched from system properties using the given property name. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `propertyName` - the name of the system property
      Returns:
        the provider for the system property, never returns null
      Since:
        6.1

    - #### gradleProperty

          @Incubating
          Provider<String> gradleProperty​(String propertyName)

      Creates a `Provider` whose value is fetched from the Gradle property of the given name. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `propertyName` - the name of the Gradle property
      Returns:
        the provider for the Gradle property, never returns null
      Since:
        6.2

    - #### gradleProperty

          @Incubating
          Provider<String> gradleProperty​(Provider<String> propertyName)

      Creates a `Provider` whose value is fetched from the Gradle property of the given name. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `propertyName` - the name of the Gradle property
      Returns:
        the provider for the Gradle property, never returns null
      Since:
        6.2

    - #### fileContents

          @Incubating
          FileContents fileContents​(RegularFile file)

      Allows lazy access to the contents of the given file. When the file contents are read at configuration time the file is automatically considered as an input to the configuration model.
      Parameters:
        `file` - the file whose contents to read.
      Returns:
        an interface that allows lazy access to the contents of the given file.
      Since:
        6.1
      See Also:
        `FileContents.getAsText()`, `FileContents.getAsBytes()`

    - #### fileContents

          @Incubating
          FileContents fileContents​(Provider<RegularFile> file)

      Allows lazy access to the contents of the given file. When the file contents are read at configuration time the file is automatically considered as an input to the configuration model.
      Parameters:
        `file` - provider of the file whose contents to read.
      Returns:
        an interface that allows lazy access to the contents of the given file.
      Since:
        6.1
      See Also:
        `FileContents.getAsText()`, `FileContents.getAsBytes()`

    - #### of

          @Incubating
          <T,​P extends ValueSourceParameters> Provider<T> of​(Class<? extends ValueSource<T,​P>> valueSourceType,
                                                                   Action<? super ValueSourceSpec<P>> configuration)

      Creates a `Provider` whose value is obtained from the given `ValueSource`. The returned provider cannot be queried at configuration time but can produce a configuration time provider via `Provider.forUseAtConfigurationTime()`.
      Parameters:
        `valueSourceType` - the type of the `ValueSource`
        `configuration` - action to configure the parameters to the given `ValueSource`
      Returns:
        the provider, never returns null
      Since:
        6.1