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

com.github.mkolisnyk.muto.generator.MutationStrategy Maven / Gradle / Ivy

The newest version!
package com.github.mkolisnyk.muto.generator;

import java.util.ArrayList;
import java.util.List;

import com.github.mkolisnyk.muto.data.MutationLocation;
import com.github.mkolisnyk.muto.reporter.MutoListener;

/**
 * @author Myk Kolisnyk
 */
public abstract class MutationStrategy {

    /**
     * .
     */
    private MutationLocation location;
    /**
     * .
     */
    private List ruleSet = null;
    /**
     * .
     */
    private List listeners = new ArrayList();
    /**
     * .
     * @return .
     */
    public final List getRuleSet() {
        if (ruleSet == null) {
            ruleSet = new ArrayList();
        }
        return ruleSet;
    }
    /**
     * .
     * @param rule .
     */
    public final void addRule(final MutationRule rule) {
        if (ruleSet == null) {
            ruleSet = new ArrayList();
        }
        ruleSet.add(rule);
    }
    /**
     * .
     * @return .
     */
    public final MutationLocation getLocation() {
        return location;
    }
    /**
     * .
     * @param locationValue .
     */
    public final void setLocation(final MutationLocation locationValue) {
        this.location = locationValue;
    }
    /**
     * @return the listeners
     */
    public final List getListeners() {
        return listeners;
    }
    /**
     * @param listenersValue the listeners to set
     */
    public final void setListeners(final List listenersValue) {
        this.listeners = listenersValue;
    }
    /**
     * .
     * @param input .
     * @return .
     */
    protected abstract String next(String input);
    /**
     * .
     * @param input .
     * @return .
     */
    public final String doNext(final String input) {
        for (MutoListener listener : this.getListeners()) {
            listener.beforeMutationStrategyRun();
        }
        String result = this.next(input);
        for (MutoListener listener : this.getListeners()) {
            listener.afterMutationStrategyRun();
        }
        return result;
    }

    /**
     * .
     * @param input .
     * @return .
     */
    public abstract boolean hasNext(final String input);
    /**
     * .
     */
    public final void reset() {
        if (ruleSet == null) {
            return;
        }
        for (MutationRule rule:ruleSet) {
            rule.reset();
        }
    }
    /**
     * .
     * @param input .
     * @return .
     */
    public abstract int total(final String input);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy