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

net.sourceforge.pmd.test.schema.RuleTestCollection Maven / Gradle / Ivy

Go to download

Parser for the XML test description format. The module has no dependency on junit or other test-only dependencies.

There is a newer version: 7.8.0
Show newest version
/*
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.test.schema;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * Collection of individual rule tests. Each test contains a copy of the
 * rule.
 *
 * @author Clément Fournier
 */
public class RuleTestCollection {

    private final List tests = new ArrayList<>();

    public void addTest(RuleTestDescriptor descriptor) {
        tests.add(Objects.requireNonNull(descriptor));
    }


    public List getTests() {
        return Collections.unmodifiableList(tests);
    }

    /**
     * Returns the last test of the collection which is focused.
     */
    public RuleTestDescriptor getFocusedTestOrNull() {
        RuleTestDescriptor focused = null;
        for (RuleTestDescriptor test : tests) {
            if (test.isFocused()) {
                focused = test;
            }
        }
        return focused;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy