/*
 * See LICENSE file in distribution for copyright and licensing information.
 */
package org.yaml.snakeyaml.nodes;

import org.yaml.snakeyaml.error.Mark;

/**
 * @see PyYAML 3.06 for more information
 */
public abstract class Node {
    private String tag;
    private Object value;
    private int hash = -1;
    private Mark startMark;
    private Mark endMark;

    public Node(final String tag, final Object value, final Mark startMark, final Mark endMark) {
        this.tag = tag;
        this.value = value;
        this.startMark = startMark;
        this.endMark = endMark;
    }

    public String getTag() {
        return this.tag;
    }

    public Object getValue() {
        return this.value;
    }

    public int hashCode() {
        if (hash == -1) {
            hash = 3;
            hash += (null == tag) ? 0 : 3 * tag.hashCode();
            hash += (null == value) ? 0 : 3 * value.hashCode();
        }
        return hash;
    }

    public boolean equals(final Object oth) {
        if (oth instanceof Node) {
            final Node nod = (Node) oth;
            return ((this.tag != null) ? this.tag.equals(nod.tag) : nod.tag == null)
                    && ((this.value != null) ? this.value.equals(nod.value) : nod.value == null);
        }
        return false;
    }

    public String toString() {
        return "<" + this.getClass().getName() + " (tag=" + getTag() + ", value=" + getValue()
                + ")>";
    }

    /**
     * For error reporting.
     * 
     * @see class variable 'id' in PyYAML
     * @return scalar, sequence, mapping
     */
    public abstract String getNodeId();

    public Mark getStartMark() {
        return startMark;
    }

    public Mark getEndMark() {
        return endMark;
    }
}

@@ -495,27 +495,253 @@
     
-this.value = value;
+if (tag == null) %7B%0A            throw new NullPointerException(%22tag in a Node is required.%22);%0A        %7D%0A        this.value = value;%0A        if (value == null) %7B%0A            throw new NullPointerException(%22value in a Node is required.%22);%0A        %7D
 %0A   

add redundant check for Null in Node