Package org.gradle.api.provider

# Interface ProviderFactory

@Incubating public interface ProviderFactory
A factory for creating instances of `Provider` and `PropertyState`.

An instance of the factory can be injected into a task or plugin by annotating a public constructor or method with `javax.inject.Inject`.

     public class MyTask extends DefaultTask {
       // injection into a constructor
       @javax.inject.Inject
       public MyTask(ProviderFactory providerFactory) { }

       // injection into a method
       @javax.inject.Inject
       public ProviderFactory getProviderFactory() {
         throw new UnsupportedOperationException();
       }
     }

An instance of the factory is also available using `Project.getProviders()`

Since:
  4.0

## Method Summary

Modifier and Type
Method
Description
`<T> PropertyState<T>`
`property(Class<T> valueType)`
Deprecated.
Use `ObjectFactory.property(Class)` instead.
`<T> Provider<T>`
`provider(Callable<? extends T> value)`
Creates a `Provider` whose value is calculated using the given `Callable`.

## Method Details

### 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.

### property

@Deprecated <T> PropertyState<T> property(Class<T> valueType)
Deprecated.
Use `ObjectFactory.property(Class)` instead.
Creates a `PropertyState` implementation to hold values of the given type.

The property will have a value equal to the default value of that type as defined by the Java language specification. Please see Oracle's Java manual for more information.

Any other data type than the standard Java data types returns a property with no value defined.

Parameters:
  `valueType` - The type of the property.
Returns:
  The property. Never returns null.