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

/**
 * Indirections declare optional data. With primitives such as
 * 'int', the transport of 'null' - values as known for example
 * to database columns gets possible.
 */
public class INDIRECTIONS implements XdrAble, java.io.Serializable {
    /** TODO */
    protected Byte optionalCharacter;
    /** TODO */
    protected Integer optionalInteger;
    /** TODO */
    protected Float optionalFloat;
    /** TODO */
    protected Double optionalDouble;
    /** TODO */
    protected STRING optionalString;
    /** TODO */
    protected ENUMFOO optionalEnum;
    /** TODO */
    protected ANSWER optionalUnion;
    /** TODO */
    protected SILLYSTRUCT optionalStruct;

    private static final long serialVersionUID = 1547342408291495675L;

    public void setOptionalCharacter(Byte optionalCharacter) {
        this.optionalCharacter = optionalCharacter;
    }
    public Byte getOptionalCharacter() {
        return this.optionalCharacter;
    }

    public void setOptionalInteger(Integer optionalInteger) {
        this.optionalInteger = optionalInteger;
    }
    public Integer getOptionalInteger() {
        return this.optionalInteger;
    }

    public void setOptionalFloat(Float optionalFloat) {
        this.optionalFloat = optionalFloat;
    }
    public Float getOptionalFloat() {
        return this.optionalFloat;
    }

    public void setOptionalDouble(Double optionalDouble) {
        this.optionalDouble = optionalDouble;
    }
    public Double getOptionalDouble() {
        return this.optionalDouble;
    }

    public void setOptionalString(STRING optionalString) {
        this.optionalString = optionalString;
    }
    public STRING getOptionalString() {
        return this.optionalString;
    }

    public void setOptionalEnum(ENUMFOO optionalEnum) {
        this.optionalEnum = optionalEnum;
    }
    public ENUMFOO getOptionalEnum() {
        return this.optionalEnum;
    }

    public void setOptionalUnion(ANSWER optionalUnion) {
        this.optionalUnion = optionalUnion;
    }
    public ANSWER getOptionalUnion() {
        return this.optionalUnion;
    }

    public void setOptionalStruct(SILLYSTRUCT optionalStruct) {
        this.optionalStruct = optionalStruct;
    }
    public SILLYSTRUCT getOptionalStruct() {
        return this.optionalStruct;
    }

    public INDIRECTIONS() {
    }

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

    public INDIRECTIONS(Byte optionalCharacter, Integer optionalInteger,
           Float optionalFloat, Double optionalDouble, STRING optionalString,
           ENUMFOO optionalEnum, ANSWER optionalUnion,
           SILLYSTRUCT optionalStruct) {
        this.optionalCharacter = optionalCharacter;
        this.optionalInteger = optionalInteger;
        this.optionalFloat = optionalFloat;
        this.optionalDouble = optionalDouble;
        this.optionalString = optionalString;
        this.optionalEnum = optionalEnum;
        this.optionalUnion = optionalUnion;
        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(optionalFloat != null);
        if (optionalFloat != null) xdr.xdrEncodeFloat(optionalFloat);
        xdr.xdrEncodeBoolean(optionalDouble != null);
        if (optionalDouble != null) xdr.xdrEncodeDouble(optionalDouble);
        xdr.xdrEncodeBoolean(optionalString != null);
        if (optionalString != null) optionalString.xdrEncode(xdr);
        xdr.xdrEncodeBoolean(optionalEnum != null);
        if (optionalEnum != null) xdr.xdrEncodeInt(optionalEnum.getEncoding());
        xdr.xdrEncodeBoolean(optionalUnion != null);
        if (optionalUnion != null) optionalUnion.xdrEncode(xdr);
        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;
        optionalFloat = xdr.xdrDecodeBoolean() ? xdr.xdrDecodeFloat() : null;
        optionalDouble = xdr.xdrDecodeBoolean() ? xdr.xdrDecodeDouble() : null;
        optionalString = xdr.xdrDecodeBoolean() ? new STRING(xdr) : null;
        optionalEnum = xdr.xdrDecodeBoolean() ? XdrEnum.create(ENUMFOO.FOO, xdr) : null;
        optionalUnion = xdr.xdrDecodeBoolean() ? new ANSWER(xdr) : null;
        optionalStruct = xdr.xdrDecodeBoolean() ? new SILLYSTRUCT(xdr) : null;
    }

    @Override
    public String toString() {
        return "INDIRECTIONS ["
        + "optionalCharacter=" + optionalCharacter + ", "
        + "optionalInteger=" + optionalInteger + ", "
        + "optionalFloat=" + optionalFloat + ", "
        + "optionalDouble=" + optionalDouble + ", "
        + "optionalString=" + optionalString + ", "
        + "optionalEnum=" + optionalEnum + ", "
        + "optionalUnion=" + optionalUnion + ", "
        + "optionalStruct=" + optionalStruct
        + "]";
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        INDIRECTIONS other = (INDIRECTIONS)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.optionalFloat, other.optionalFloat)) return false;
        if (! java.util.Objects.equals(this.optionalDouble, other.optionalDouble)) return false;
        if (! java.util.Objects.equals(this.optionalString, other.optionalString)) return false;
        if (! java.util.Objects.equals(this.optionalEnum, other.optionalEnum)) return false;
        if (! java.util.Objects.equals(this.optionalUnion, other.optionalUnion)) 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 INDIRECTIONS.java
