com.github.mkolisnyk.muto.generator.MutationStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of muto Show documentation
Show all versions of muto Show documentation
Automated Mutation Testing Framework
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);
}