package com.bjtdba.system.vo;

import java.util.ArrayList;
import java.util.List;

public class RegionsVo {
    private Integer id;

    private String name;

    private String pid;

    private List<RegionsVo> children=new ArrayList<RegionsVo>();

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public List<RegionsVo> getChildren() {
        return children;
    }

    public void setChildren(List<RegionsVo> children) {
        this.children = children;
    }


    public static RegionsVo findNode(List<RegionsVo> nodes, Integer id) {
        List<RegionsVo> finds = new ArrayList<RegionsVo>();
        findNode(nodes, id, finds);
        return finds.size() != 0 ? finds.get(0) : null;
    }

    public static void findNode(List<RegionsVo> nodes, Integer id, List<RegionsVo> finds) {
        for (RegionsVo node : nodes) {
            if (id.equals(node.getId()))
                finds.add(node);

            findNode(node.getChildren(), id, finds);
        }
    }
}
