berlin.yuna.survey.model.Condition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of surveys Show documentation
Show all versions of surveys Show documentation
Survey is a plain java library to provide a base for surveys / questionnaires. It also provides a
function to generate diagrams and to measure answer times.
package berlin.yuna.survey.model;
import berlin.yuna.survey.logic.DiagramExporter;
/**
* {@link Condition} is used for back and forward transitions/{@link Route} in a {@link berlin.yuna.survey.model.types.FlowItem}
*
* @param answer type should be the same as the {@link berlin.yuna.survey.model.types.FlowItem} type
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public abstract class Condition {
/**
* Optional {@code label}
* Used by rendering diagrams {@link DiagramExporter}
*/
private final String label;
/**
* Constructor without label
*/
public Condition() {
this(null);
}
/**
* Constructor with label
*
* @param label (optional) used for render diagrams {@link DiagramExporter}
*/
public Condition(final String label) {
this.label = label;
}
/**
* Gets the defined label for this {@link Condition}
*
* @return defined label
*/
public String getLabel() {
return label;
}
/**
* Specifies what happens on on the transition with the given answer
*
* @param answer passed for optional usage
* @return {@code true} if transition is allowed else {@code false}
*/
public abstract boolean apply(final T answer);
}