org.gradle.api.model

## Interface ObjectFactory

-     @Incubating
      public interface ObjectFactory

  A factory for creating various kinds of model objects.

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

  Since:
    4.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T extends Named> T` | `named(Class<T> type, String name)` Creates a simple immutable `Named` object of the given type and name.
    `<T> T` | `newInstance(Class<? extends T> type, Object... parameters)` Create a new instance of T, using `parameters` as the construction parameters.

- - ### Method Detail

    - #### named

          <T extends Named> T named(Class<T> type,
                                  String name)
                                throws ObjectInstantiationException

      Creates a simple immutable `Named` object of the given type and name.

      The given type can be an interface that extends `Named` or an abstract class that 'implements' `Named`. An abstract class, if provided:

      - Must provide a zero-args constructor that is not private.
      - Must not define or inherit any instance fields.
      - Should not provide an implementation for `Named.getName()` and should define this method as abstract. Any implementation will be overridden.
      - Must not define or inherit any other abstract methods.

      An interface, if provided, must not define or inherit any other methods.

      Objects created using this method are not decorated or extensible.

      Throws:
        `ObjectInstantiationException` - On failure to create the new instance.
      Since:
        4.0

    - #### newInstance

          <T> T newInstance(Class<? extends T> type,
                          Object... parameters)
                        throws ObjectInstantiationException

      Create a new instance of T, using `parameters` as the construction parameters.

      The type must be a non-abstract class.

      Objects created using this method are decorated and extensible, meaning that they have DSL support mixed in and can be extended using the `extensions` property, similar to the `Project` object.

      An @Inject annotation is required on any constructor that accepts parameters because JSR-330 semantics for dependency injection are used. In addition to those parameters provided as an argument to this method, the following services are also available for injection:

      - `ObjectFactory`.
      - `ProjectLayout`.
      - `ProviderFactory`.
      Throws:
        `ObjectInstantiationException` - On failure to create the new instance.
      Since:
        4.2