package fr.titionfire.ffsaf.utils;

import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@RegisterForReflection
public class TreeNode<T> {
    private T data;
    private TreeNode<T> left;
    private TreeNode<T> right;

    public TreeNode(T data) {
        this(data, null, null);
    }

    public int death() {
        int dg = 0;
        int dd = 0;

        if (this.right != null)
            dg = this.right.death();

        if (this.left != null)
            dg = this.left.death();

        return 1 + Math.max(dg, dd);
    }
}
