package com.inspect.metadata.area.domain.vo;

import com.inspect.metadata.area.domain.BaseDataArea;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

@Setter
@Getter
public class TreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;
    private String label;
    @JsonInclude(Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect() {
    }

    public TreeSelect(BaseDataArea area) {
        this.id = area.getAreaId();
        this.label = area.getAreaName();
        this.children = area.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

}
