/*
 * 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 INDIRECTIONS2 implements XdrAble {
    /** TODO */
    public Byte optionalCharacter;
    /** TODO */
    public Integer optionalInteger;
    /** TODO */
    public Integer optionalEnum;
    /** TODO */
    public TREE2 optionalStruct;

    public INDIRECTIONS2() {
    }

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

    public INDIRECTIONS2(Byte optionalCharacter, Integer optionalInteger,
           Integer optionalEnum, TREE2 optionalStruct) {
        this.optionalCharacter = optionalCharacter;
        this.optionalInteger = optionalInteger;
        this.optionalEnum = optionalEnum;
        this.optionalStruct = optionalStruct;
    }

    @Override
    public void xdrEncode(XdrEncodingStream xdr)
           throws OncRpcException, IOException {
        xdr.xdrEncodeBoolean(optionalCharacter != null);
        if (optionalCharacter != null) xdr.xdrEncodeByte(optionalCharacter);
        xdr.xdrEncodeBoolean(optionalInteger != null);
        if (optionalInteger != null) xdr.xdrEncodeInt(optionalInteger);
        xdr.xdrEncodeBoolean(optionalEnum != null);
        if (optionalEnum != null) xdr.xdrEncodeInt(optionalEnum);
        xdr.xdrEncodeBoolean(optionalStruct != null);
        if (optionalStruct != null) optionalStruct.xdrEncode(xdr);
    }

    @Override
    public void xdrDecode(XdrDecodingStream xdr)
           throws OncRpcException, IOException {
        optionalCharacter = xdr.xdrDecodeBoolean() ? xdr.xdrDecodeByte() : null;
        optionalInteger = xdr.xdrDecodeBoolean() ? xdr.xdrDecodeInt() : null;
        optionalEnum = xdr.xdrDecodeBoolean() ? xdr.xdrDecodeInt() : null;
        optionalStruct = xdr.xdrDecodeBoolean() ? new TREE2(xdr) : null;
    }

    @Override
    public String toString() {
        return "INDIRECTIONS2 ["
        + "optionalCharacter=" + optionalCharacter + ", "
        + "optionalInteger=" + optionalInteger + ", "
        + "optionalEnum=" + optionalEnum + ", "
        + "optionalStruct=" + optionalStruct
        + "]";
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        INDIRECTIONS2 other = (INDIRECTIONS2)obj;
        if (! java.util.Objects.equals(this.optionalCharacter, other.optionalCharacter)) return false;
        if (! java.util.Objects.equals(this.optionalInteger, other.optionalInteger)) return false;
        if (! java.util.Objects.equals(this.optionalEnum, other.optionalEnum)) return false;
        if (! java.util.Objects.equals(this.optionalStruct, other.optionalStruct)) return false;
        return true;
    }

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

}
// End of INDIRECTIONS2.java
