/*
 * Automatically generated by jrpcgen 1.1.6 on 21.02.24 22:11
 * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
 * See http://remotetea.sourceforge.net for details
 */
package tests.org.acplt.oncrpc.jrpcgen;
import org.acplt.oncrpc.*;
import java.io.IOException;

/** TODO */
public class TREE implements XdrAble, java.io.Serializable {
    /** TODO */
    protected String key;
    /** TODO */
    protected String value;
    /** TODO */
    protected TREE left;
    /** TODO */
    protected TREE right;

    private static final long serialVersionUID = -4116891816662345112L;

    public void setKey(String key) {
        this.key = key;
    }
    public String getKey() {
        return this.key;
    }

    public void setValue(String value) {
        this.value = value;
    }
    public String getValue() {
        return this.value;
    }

    public void setLeft(TREE left) {
        this.left = left;
    }
    public TREE getLeft() {
        return this.left;
    }

    public void setRight(TREE right) {
        this.right = right;
    }
    public TREE getRight() {
        return this.right;
    }

    public TREE() {
    }

    public TREE(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        xdrDecode(xdr);
    }

    public TREE(String key, String value, TREE left, TREE right) {
        this.key = key;
        this.value = value;
        this.left = left;
        this.right = right;
    }

    @Override
    public void xdrEncode(XdrEncodingStream xdr)
           throws OncRpcException, IOException {
        for (TREE $current = this; $current != null; $current = $current.right) {
            xdr.xdrEncodeString($current.key);
            xdr.xdrEncodeString($current.value);
            xdr.xdrEncodeBoolean($current.left != null);
            if ($current.left != null) $current.left.xdrEncode(xdr);
            xdr.xdrEncodeBoolean($current.right != null);
        }
    }

    @Override
    public void xdrDecode(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        for (TREE $current = this; $current != null; $current = $current.right) {
            $current.key = xdr.xdrDecodeString();
            $current.value = xdr.xdrDecodeString();
            $current.left = xdr.xdrDecodeBoolean() ? new TREE(xdr) : null;
            $current.right = xdr.xdrDecodeBoolean() ? new TREE() : null;
        }
    }

    @Override
    public String toString() {
        return "TREE ["
        + "key=" + key + ", "
        + "value=" + value + ", "
        + "left=" + left + ", "
        + "right=" + right
        + "]";
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        TREE other = (TREE)obj;
        if (! java.util.Objects.equals(this.key, other.key)) return false;
        if (! java.util.Objects.equals(this.value, other.value)) return false;
        if (! java.util.Objects.equals(this.left, other.left)) return false;
        if (! java.util.Objects.equals(this.right, other.right)) return false;
        return true;
    }

    @Override
    public int hashCode() {
        return XdrHashCode.hashCode(this);
    }

}
// End of TREE.java
