berlin.yuna.survey.model.HistoryItemJson 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.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()));
}
});
}
}