Search in sources :

Example 1 with ManagedInstance

use of org.gradle.model.internal.manage.instance.ManagedInstance in project gradle by gradle.

the class NodeBackedModelMap method put.

@Override
public void put(String name, T instance) {
    Class<T> type = Cast.uncheckedCast(instance.getClass());
    ModelRuleDescriptor descriptor = sourceDescriptor.append("put()");
    if (instance instanceof ManagedInstance) {
        ManagedInstance target = (ManagedInstance) instance;
        modelNode.addReference(name, target.getManagedType(), target.getBackingNode(), descriptor);
    } else {
        modelNode.addLink(ModelRegistrations.unmanagedInstance(ModelReference.of(modelNode.getPath().child(name), type), Factories.constant(instance)).descriptor(descriptor).build());
    }
}
Also used : ManagedInstance(org.gradle.model.internal.manage.instance.ManagedInstance) ModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor)

Aggregations

ModelRuleDescriptor (org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor)1 ManagedInstance (org.gradle.model.internal.manage.instance.ManagedInstance)1