Blame view

Node.java 797 Bytes
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
package com.meishu.util.tree;

import lombok.Data;

@Data
public class Node implements Comparable<Node> {

    //主键
    private String id;

    //同级节点第几个元素
    private String number;

    //1.1
    private String text;

    //父节点
    private String parentId;

    private int level;

    public Node(String id, String number, String parentId, int level) {
        this.id = id;
        this.number = number;
        this.parentId = parentId;
        this.level = level;
    }

    @Override
    public int compareTo(Node o) {
        if (this.level != o.level) {
            return o.level - this.level;
        } else {
            if(this.number==null){
                return -1;
            }
            return this.number.compareTo(o.number);
        }
    }


}