use of org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor in project gradle by gradle.
the class NodeBackedModelMap method named.
@Override
public void named(String name, Class<? extends RuleSource> ruleSource) {
viewState.assertCanMutate();
ModelRuleDescriptor descriptor = sourceDescriptor.append("named(%s, %s)", name, ruleSource.getName());
ModelReference<T> subject = ModelReference.of(modelNode.getPath().child(name), elementType);
modelNode.defineRulesForLink(ModelActionRole.Defaults, new FilteringActionWrapper<T>(elementFilter, subject, DirectNodeNoInputsModelAction.of(subject, descriptor, new ApplyRuleSource(ruleSource))));
}
use of org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor in project gradle by gradle.
the class NodeBackedModelMap method named.
@Override
public void named(String name, Action<? super T> configAction) {
viewState.assertCanMutate();
ModelRuleDescriptor descriptor = sourceDescriptor.append("named(%s)", name);
ModelReference<T> subject = ModelReference.of(modelNode.getPath().child(name), elementType);
modelNode.applyToLink(ModelActionRole.Mutate, new FilteringActionWrapper<T>(elementFilter, subject, NoInputsModelAction.of(subject, descriptor, configAction)));
}
use of org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor in project gradle by gradle.
the class NodeBackedModelMap method mutateChildren.
private <E> void mutateChildren(ModelActionRole role, ModelType<E> filterType, String operation, Action<? super E> configAction) {
viewState.assertCanMutate();
ModelRuleDescriptor descriptor = sourceDescriptor.append(operation);
ModelReference<E> subject = ModelReference.of(filterType);
modelNode.applyTo(allLinks(elementFilter.withType(filterType)), role, NoInputsModelAction.of(subject, descriptor, configAction));
}
use of org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor 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());
}
}
use of org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor in project gradle by gradle.
the class NodeBackedModelSet method create.
@Override
public void create(final Action<? super T> action) {
state.assertCanMutate();
String name = String.valueOf(modelNode.getLinkCount(ModelNodes.withType(elementType)));
ModelPath childPath = modelNode.getPath().child(name);
final ModelRuleDescriptor descriptor = this.descriptor.append("create()");
NodeInitializer nodeInitializer = creatorStrategy.initializer(elementType, Specs.<ModelType<?>>satisfyAll());
ModelRegistration registration = ModelRegistrations.of(childPath, nodeInitializer).descriptor(descriptor).action(ModelActionRole.Initialize, NoInputsModelAction.of(ModelReference.of(childPath, elementType), descriptor, action)).build();
modelNode.addLink(registration);
}
Aggregations