package fr.titionfire.ffsaf.rest.data;

import fr.titionfire.ffsaf.data.model.TreeModel;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
@RegisterForReflection
public class TreeData {
    private Long id;
    private Long category;
    private Integer level;
    private Long match;
    private TreeData left;
    private TreeData right;

    public static TreeData fromModel(TreeModel model) {
        if (model == null)
            return null;

        return new TreeData(model.getId(), model.getCategory(), model.getLevel(), model.getMatch().getId(),
                fromModel(model.getLeft()), fromModel(model.getRight()));
    }
}
