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

guru.nidi.codeassert.config.CollectorTemplate Maven / Gradle / Ivy

There is a newer version: 0.9.15
Show newest version
/*
 * Copyright © 2015 Stefan Niederhauser ([email protected])
 *
 * 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 guru.nidi.codeassert.config;

import java.util.*;

public final class CollectorTemplate
        extends BaseCollector> implements Iterable> {
    private final List> configs = new ArrayList<>();

    private CollectorTemplate() {
    }

    public static  CollectorTemplate forA(Class> coll) {
        return new CollectorTemplate<>();
    }

    public static  CollectorTemplate of(Class action) {
        return new CollectorTemplate<>();
    }

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

    @Override
    protected CollectorTemplate config(CollectorConfig... configs) {
        for (final CollectorConfig config : configs) {
            this.configs.add(config.ignoringUnused());
        }
        return this;
    }

    @Override
    public ActionResult accept(Object issue) {
        throw new UnsupportedOperationException(
                "This is just a template. Apply it to a real Collector using .configs()");
    }

    @Override
    protected ActionResult doAccept(Object issue, A action) {
        throw new UnsupportedOperationException(
                "This is just a template. Apply it to a real Collector using .configs()");
    }

    @Override
    protected List unused(UsageCounter counter) {
        throw new UnsupportedOperationException(
                "This is just a template. Apply it to a real Collector using .configs()");
    }

    @Override
    public String toString() {
        return configs.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy