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

berlin.yuna.survey.model.Condition Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 0.1.110
Show newest version
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);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy