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

org.conqat.engine.sourcecode.coverage.DecisionProbeConfiguration Maven / Gradle / Ivy

The newest version!
package org.conqat.engine.sourcecode.coverage;

import java.io.Serializable;
import java.util.Objects;

import org.conqat.lib.commons.test.IndexValueClass;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * A configuration for the individual conditions in a decision. As an example for the decision "if
 * (val == 1 || val == 2 || val == 3), the configuration * "T || F || _" would indicate that the
 * first condition was true, the second one was false and the third one is a "Don't care".
 */
@IndexValueClass(containedInBackup = true)
public class DecisionProbeConfiguration implements Serializable {

	private static final long serialVersionUID = 1L;

	@JsonProperty("executionCount")
	private int executionCount;

	@JsonProperty("description")
	private final String description;

	/**
	 * The overall truth value of the combined decision, based on the valuation in
	 * {{@link #description}.
	 */
	@JsonProperty("decisionValue")
	private final boolean decisionValue;

	@JsonCreator
	public DecisionProbeConfiguration(@JsonProperty("decisionValue") boolean decisionValue,
			@JsonProperty("executionCount") int executionCount, @JsonProperty("description") String description) {
		this.decisionValue = decisionValue;
		this.description = description;
		this.executionCount = executionCount;
	}

	/** @see #description */
	public String getDescription() {
		return description;
	}

	/** @see #decisionValue */
	public boolean getDecisionValue() {
		return decisionValue;
	}

	/** @see #executionCount */
	public int getExecutionCount() {
		return executionCount;
	}

	@Override
	public String toString() {
		return executionCount + "(" + description + ")";
	}

	/**
	 * Returns whether two probe configurations have same {@link #description} and
	 * {@link #decisionValue}.
	 */
	public static boolean haveSameDescriptionAndDecisionValue(DecisionProbeConfiguration configuration1,
			DecisionProbeConfiguration configuration2) {
		return configuration1.decisionValue == configuration2.decisionValue
				&& Objects.equals(configuration1.description, configuration2.description);
	}

	/** Increases execution count by given amount. */
	public void increaseExecutionCount(int amount) {
		executionCount += amount;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy