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

berlin.yuna.survey.model.HistoryItemJson 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.103
Show newest version
package berlin.yuna.survey.model;

import berlin.yuna.survey.model.types.FlowItem;

import java.util.Optional;

@SuppressWarnings({"unused", "UnusedReturnValue"})
public class HistoryItemJson extends HistoryItemBase {

    public HistoryItemJson() {
        super();
    }

    public HistoryItemJson(final String label) {
        super(label);
    }

    public HistoryItemJson(final HistoryItemBase item, final String answer) {
        super(item.getLabel(), answer, item.getCreatedAt(), item.getState());
    }

    public static Optional of(final FlowItem flowStart, final HistoryItemBase item) {
        return flowStart.get(item.getLabel()).stream().findAny().map(flowItem -> {
            if (item instanceof HistoryItemJson historyItemJson) {
                return historyItemJson;
            } else {
                return new HistoryItemJson(item, flowItem.toJson(item.getAnswer()));
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy