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

org.gradle.api.internal.DelegatingDomainObjectSet Maven / Gradle / Ivy

There is a newer version: 8.6
Show newest version
/*
 * Copyright 2011 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.internal;

import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.DomainObjectCollection;
import org.gradle.api.DomainObjectSet;
import org.gradle.api.provider.Provider;
import org.gradle.api.specs.Spec;
import org.gradle.api.specs.Specs;
import org.gradle.util.ConfigureUtil;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

public class DelegatingDomainObjectSet implements DomainObjectSet {
    private final DomainObjectSet backingSet;

    public DelegatingDomainObjectSet(DomainObjectSet backingSet) {
        this.backingSet = backingSet;
    }

    @Override
    public DomainObjectSet matching(Closure spec) {
        return matching(Specs.convertClosureToSpec(spec));
    }

    @Override
    public DomainObjectSet matching(Spec spec) {
        return backingSet.matching(spec);
    }

    @Override
    public  DomainObjectSet withType(Class type) {
        return backingSet.withType(type);
    }

    @Override
    public void all(Action action) {
        backingSet.all(action);
    }

    @Override
    public void all(Closure action) {
        all(ConfigureUtil.configureUsing(action));
    }

    @Override
    public void configureEach(Action action) {
        backingSet.configureEach(action);
    }

    @Override
    public Action whenObjectAdded(Action action) {
        return backingSet.whenObjectAdded(action);
    }

    @Override
    public void whenObjectAdded(Closure action) {
        whenObjectAdded(ConfigureUtil.configureUsing(action));
    }

    @Override
    public Action whenObjectRemoved(Action action) {
        return backingSet.whenObjectRemoved(action);
    }

    @Override
    public void whenObjectRemoved(Closure action) {
        whenObjectRemoved(ConfigureUtil.configureUsing(action));
    }

    @Override
    public  DomainObjectCollection withType(Class type, Action configureAction) {
        return backingSet.withType(type, configureAction);
    }

    @Override
    public  DomainObjectCollection withType(Class type, Closure configureClosure) {
        return withType(type, ConfigureUtil.configureUsing(configureClosure));
    }

    @Override
    public void addLater(Provider provider) {
        backingSet.addLater(provider);
    }

    @Override
    public void addAllLater(Provider> provider) {
        backingSet.addAllLater(provider);
    }

    @Override
    public boolean add(T o) {
        return backingSet.add(o);
    }

    @Override
    public boolean addAll(Collection c) {
        return backingSet.addAll(c);
    }

    @Override
    public void clear() {
        backingSet.clear();
    }

    @Override
    public boolean contains(Object o) {
        return backingSet.contains(o);
    }

    @Override
    public boolean containsAll(Collection c) {
        return backingSet.containsAll(c);
    }

    @Override
    public boolean isEmpty() {
        return backingSet.isEmpty();
    }

    @Override
    public Iterator iterator() {
        return backingSet.iterator();
    }

    @Override
    public boolean remove(Object o) {
        return backingSet.remove(o);
    }

    @Override
    public boolean removeAll(Collection c) {
        return backingSet.removeAll(c);
    }

    @Override
    public boolean retainAll(Collection c) {
        return backingSet.retainAll(c);
    }

    @Override
    public int size() {
        return backingSet.size();
    }

    @Override
    public Object[] toArray() {
        return backingSet.toArray();
    }

    @Override
    public  T[] toArray(T[] a) {
        return backingSet.toArray(a);
    }

    @Override
    public Set findAll(Closure spec) {
        return backingSet.findAll(spec);
    }
}