/*
 * 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;

/**
 * Definition of a single-linked list.
 * 
 * <p>Each node takes an integer value
 * and holds a reference to the next node,
 * if present.
 */
public class LINKEDLIST implements XdrAble, java.io.Serializable {
    /** TODO */
    protected int foo;
    /** TODO */
    protected LINKEDLIST next;

    private static final long serialVersionUID = -9187504517170663946L;

    public void setFoo(int foo) {
        this.foo = foo;
    }
    public int getFoo() {
        return this.foo;
    }

    public void setNext(LINKEDLIST next) {
        this.next = next;
    }
    public LINKEDLIST getNext() {
        return this.next;
    }

    public LINKEDLIST() {
    }

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

    public LINKEDLIST(int foo, LINKEDLIST next) {
        this.foo = foo;
        this.next = next;
    }

    @Override
    public void xdrEncode(XdrEncodingStream xdr)
           throws OncRpcException, IOException {
        for (LINKEDLIST $current = this; $current != null; $current = $current.next) {
            xdr.xdrEncodeInt($current.foo);
            xdr.xdrEncodeBoolean($current.next != null);
        }
    }

    @Override
    public void xdrDecode(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        for (LINKEDLIST $current = this; $current != null; $current = $current.next) {
            $current.foo = xdr.xdrDecodeInt();
            $current.next = xdr.xdrDecodeBoolean() ? new LINKEDLIST() : null;
        }
    }

    @Override
    public String toString() {
        return "LINKEDLIST ["
        + "foo=" + foo + ", "
        + "next=" + next
        + "]";
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        LINKEDLIST other = (LINKEDLIST)obj;
        if (this.foo != other.foo) return false;
        if (! java.util.Objects.equals(this.next, other.next)) return false;
        return true;
    }

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

}
// End of LINKEDLIST.java
