All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.api.ExtensiblePolymorphicDomainObjectContainer Maven / Gradle / Ivy

There is a newer version: 8.6
Show newest version
/*
 * Copyright 2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gradle.api;

import groovy.lang.Closure;
import org.gradle.api.internal.rules.NamedDomainObjectFactoryRegistry;

/**
 * A {@link org.gradle.api.PolymorphicDomainObjectContainer} that can be extended at runtime to
 * create elements of new types.
 *
 * 

You can create an instance of this type using the factory method {@link org.gradle.api.model.ObjectFactory#polymorphicDomainObjectContainer(Class)}.

* * @param the (base) container element type */ public interface ExtensiblePolymorphicDomainObjectContainer extends PolymorphicDomainObjectContainer, NamedDomainObjectFactoryRegistry { /** * Registers a factory for creating elements of the specified type. Typically, the specified type * is an interface type. * * @param type the type of objects created by the factory * @param factory the factory to register * @param the type of objects created by the factory * * @throws IllegalArgumentException if the specified type is not a subtype of the container element type */ @Override void registerFactory(Class type, NamedDomainObjectFactory factory); /** * Registers a factory for creating elements of the specified type. * Typically, the specified type is an interface type. * * @param type the type of objects created by the factory * @param factory the factory to register * @param the type of objects created by the factory * * @throws IllegalArgumentException if the specified type is not a subtype of the container element type */ void registerFactory(Class type, final Closure factory); /** * Registers a binding from the specified "public" domain object type to the specified implementation type. * Whenever the container is asked to create an element with the binding's public type, it will instantiate * the binding's implementation type. If the implementation type has a constructor annotated with * {@link javax.inject.Inject}, its arguments will be injected. * *

In general, registering a binding is preferable over implementing and registering a factory. * * @param type a public domain object type * @param implementationType the corresponding implementation type * @param a public domain object type */ void registerBinding(Class type, final Class implementationType); }