/*
 * 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 ANSWER implements XdrAble, java.io.Serializable {
    /** TODO */
    public int value;
    /** TODO */
    public int wrong;
    /** TODO */
    public int the_answer;
    /** TODO */
    public int check_hash;

    private static final long serialVersionUID = 5165359675382683141L;

    public ANSWER() {
    }

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

    public ANSWER(int value, Object value_) {
        this.value = value;
        switch ( value ) {
        case 40:
        case 41:
            this.wrong = ((Number)value_).intValue();
            break;
        case 42:
            this.the_answer = ((Number)value_).intValue();
            break;
        default:
            this.check_hash = ((Number)value_).intValue();
            break;
        }
    }

    @Override
    public void xdrEncode(XdrEncodingStream xdr)
           throws OncRpcException, IOException {
        xdr.xdrEncodeInt(value);
        switch ( value ) {
        case 40:
        case 41:
            xdr.xdrEncodeInt(wrong);
            break;
        case 42:
            xdr.xdrEncodeInt(the_answer);
            break;
        default:
            xdr.xdrEncodeInt(check_hash);
            break;
        }
    }

    @Override
    public void xdrDecode(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        value = xdr.xdrDecodeInt();
        switch ( value ) {
        case 40:
        case 41:
            wrong = xdr.xdrDecodeInt();
            break;
        case 42:
            the_answer = xdr.xdrDecodeInt();
            break;
        default:
            check_hash = xdr.xdrDecodeInt();
            break;
        }
    }

    @Override
    public String toString() {
        String ret = "ANSWER=";
        switch ( value ) {
        case 40:
        case 41:
            ret += this.wrong;
            break;
        case 42:
            ret += this.the_answer;
            break;
        default:
            ret += this.check_hash;
            break;
        }
        return ret;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        ANSWER other = (ANSWER)obj;
        if (this.value != other.value) return false;
        boolean ret = true;
        switch ( value ) {
        case 40:
        case 41:
            ret = this.wrong == other.wrong;
            break;
        case 42:
            ret = this.the_answer == other.the_answer;
            break;
        default:
            ret = this.check_hash == other.check_hash;
            break;
        }
        return ret;
    }

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

    public static void xdrEncodeFixedVector(XdrEncodingStream xdr, ANSWER[] vector, int size)
           throws OncRpcException, IOException {
        if (vector.length != size) {
            throw new IllegalArgumentException("array size does not match protocol specification");
        }

        for (int index = 0; index < size; index++) {
            vector[index].xdrEncode(xdr);
        }
    }

    public static ANSWER[] xdrDecodeFixedVector(XdrDecodingStream xdr, int size)
           throws OncRpcException, IOException {
        ANSWER[] vector = new ANSWER[size];

        for (int index = 0; index < size; index++) {
            vector[index] = new ANSWER(xdr);
        }

        return vector;
    }

    public static void xdrEncodeDynamicVector(XdrEncodingStream xdr, ANSWER[] vector)
           throws OncRpcException, IOException {
        xdr.xdrEncodeInt(vector.length);
        xdrEncodeFixedVector(xdr, vector, vector.length);
    }

    public static ANSWER[] xdrDecodeDynamicVector(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        return xdrDecodeFixedVector(xdr, xdr.xdrDecodeInt());
    }

}
// End of ANSWER.java
