public void onAddToContainer(NamedDomainObjectCollection<ArtifactRepository> container) { isPartOfContainer = true; }
public <S extends T> NamedDomainObjectCollection<S> withType(Class<S> type) { return filtered(createFilter(type)); }
public NamedDomainObjectCollection<T> matching(Spec<? super T> spec) { return filtered(createFilter(spec)); }
public NamedDomainObjectCollection<T> matching(Closure spec) { return matching(Specs.<T>convertClosureToSpec(spec)); }
public static <I, C extends NamedDomainObjectCollection<I>> ModelRegistrations.Builder registration( final ModelReference<C> containerReference, final Transformer<? extends C, ? super MutableModelNode> containerFactory, final Namer<? super I> namer, String descriptor, final Transformer<String, String> itemDescriptorGenerator ) { final ModelPath containerPath = containerReference.getPath(); final ModelType<C> containerType = containerReference.getType(); assert containerPath != null : "container reference path cannot be null"; return ModelRegistrations.of(containerPath) .action(ModelActionRole.Create, new Action<MutableModelNode>() { public void execute(final MutableModelNode containerNode) { final C container = containerFactory.transform(containerNode); containerNode.setPrivateData(containerType, container); container.all(new Action<I>() { public void execute(final I item) { final String name = namer.determineName(item); // For now, ignore elements added after the container has been closed if (!containerNode.isMutable()) { LOGGER.debug("Ignoring element '{}' added to '{}' after it is closed.", containerPath, name); return; } if (!containerNode.hasLink(name)) { ModelRegistration itemRegistration = ModelRegistrations .unmanagedInstanceOf( ModelReference.of(containerPath.child(name), new DslObject(item).getDeclaredType()), new ExtractFromParentContainer<I, C>(name, containerType) ) .descriptor(itemDescriptorGenerator.transform(name)) .build(); containerNode.addLink(itemRegistration); } } }); container.whenObjectRemoved(new Action<I>() { public void execute(I item) { String name = namer.determineName(item); containerNode.removeLink(name); } }); } }) .descriptor(descriptor); }
private NamedDomainObjectCollection<ProductFlavorConfig> getProductFlavorConfigs(final Project project) { return findFlipTheSwitchExtension(project).productFlavors(); }
void onAddToContainer(NamedDomainObjectCollection<ArtifactRepository> container);