package ru.job4j.tree;

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

/**
 * Class Node.
 *
 * @author Alexey Rastorguev (rastorguev00@gmail.com)
 * @version 0.1
 * @since 28.12.2017
 */
public class Node<E> {
    private final List<Node<E>> children = new ArrayList<>();
    private final E value;

    public Node(final E value) {
        this.value = value;
    }

    public void add(Node<E> child) {
        this.children.add(child);
    }

    public List<Node<E>> leaves() {
        return this.children;
    }

    public boolean eqValue(E that) {
        return this.value.equals(that);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Node<?> node = (Node<?>) o;

        return value != null ? value.equals(node.value) : node.value == null;
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + (value != null ? value.hashCode() : 0);
        return result;
    }
}

@@ -676,16 +676,30 @@
 is == o)
+ %7B%0A           
  return 
@@ -700,24 +700,34 @@
 eturn true;%0A
+        %7D%0A
         if (
@@ -766,16 +766,30 @@
 Class())
+ %7B%0A           
  return 
@@ -794,16 +794,26 @@
 n false;
+%0A        %7D
 %0A%0A      

modify Node, package tree.