====
    Copyright Kroxylicious Authors.

    Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
====

// THIS CODE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.

package org.apache.kafka.common.message;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.kafka.common.errors.UnsupportedVersionException;
import org.apache.kafka.common.protocol.ApiMessage;
import org.apache.kafka.common.protocol.Message;
import org.apache.kafka.common.protocol.MessageSizeAccumulator;
import org.apache.kafka.common.protocol.MessageUtil;
import org.apache.kafka.common.protocol.ObjectSerializationCache;
import org.apache.kafka.common.protocol.Readable;
import org.apache.kafka.common.protocol.Writable;
import org.apache.kafka.common.protocol.types.ArrayOf;
import org.apache.kafka.common.protocol.types.CompactArrayOf;
import org.apache.kafka.common.protocol.types.Field;
import org.apache.kafka.common.protocol.types.RawTaggedField;
import org.apache.kafka.common.protocol.types.RawTaggedFieldWriter;
import org.apache.kafka.common.protocol.types.Schema;
import org.apache.kafka.common.protocol.types.Type;
import org.apache.kafka.common.utils.ByteUtils;
import org.apache.kafka.common.utils.ImplicitLinkedHashCollection;
import org.apache.kafka.common.utils.ImplicitLinkedHashMultiCollection;

import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection;

public class FetchRequestData implements ApiMessage {

    UNKNOWN - ClusterId clusterId;
    int replicaId;
    UNKNOWN - ReplicaState replicaState;
    int maxWaitMs;
    int minBytes;
    int maxBytes;
    UNKNOWN - IsolationLevel isolationLevel;
    int sessionId;
    int sessionEpoch;
    FetchTopicCollection topics;
    ForgottenTopicCollection forgottenTopicsData;
    UNKNOWN - RackId rackId;
    private List<RawTaggedField> _unknownTaggedFields;



    public static final Schema[] SCHEMAS = new Schema[] {
        SCHEMA_0,
        SCHEMA_1,
        SCHEMA_2,
        SCHEMA_3,
        SCHEMA_4,
        SCHEMA_5,
        SCHEMA_6,
        SCHEMA_7,
        SCHEMA_8,
        SCHEMA_9,
        SCHEMA_10,
        SCHEMA_11,
        SCHEMA_12,
        SCHEMA_13,
        SCHEMA_14,
        SCHEMA_15,
        SCHEMA_16
    };

    public static final short LOWEST_SUPPORTED_VERSION = 0;
    public static final short HIGHEST_SUPPORTED_VERSION = 16;

    public FetchRequestData(Readable _readable, short _version) {
        read(_readable, _version);
    }

    public FetchRequestData() {
        this.clusterId = null;
        this.replicaId = -1;
        this.replicaState = ;
        this.maxWaitMs = ;
        this.minBytes = ;
        this.maxBytes = 0x7fffffff;
        this.isolationLevel = 0;
        this.sessionId = 0;
        this.sessionEpoch = -1;
        this.topics = new FetchTopicCollection(0);
        this.forgottenTopicsData = new ForgottenTopicCollection(0);
        this.rackId = ;
    }

    /** The API key */
    @Override
    public short apiKey() {
        return 1;
    }

    /** @return the lowest valid version for this RPC. */
    @Override
    public short lowestSupportedVersion() {
        return 0;
    }

    /** @return the highest valid version for this message. */
    @Override
    public short highestSupportedVersion() {
        return 16;
    }

    @Override
    public void read(Readable _readable, short _version) {
        // TODO
    }

    @Override
    public void write(Writeable _writeable, ObjectSerializationCache _cache, short _version) {
        // TODO
    }

    @Override
    public void addSize(MessageSizeAccumulator _size, ObjectSerializationCache _cache, short _version) {
        // TODO
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof FetchRequestData)) return false;
        FetchRequestData other = (FetchRequestData) obj;
        if (this.clusterId == null) {
            if (other.clusterId != null) return false;
        } else {
            if (!this.clusterId.equals(other.clusterId)) return false;
        }
        if (replicaId != other.replicaId) return false;
        if (this.replicaState == null) {
            if (other.replicaState != null) return false;
        } else {
            if (!this.replicaState.equals(other.replicaState)) return false;
        }
        if (maxWaitMs != other.maxWaitMs) return false;
        if (minBytes != other.minBytes) return false;
        if (maxBytes != other.maxBytes) return false;
        if (isolationLevel != other.isolationLevel) return false;
        if (sessionId != other.sessionId) return false;
        if (sessionEpoch != other.sessionEpoch) return false;
        if (this.topics == null) {
            if (other.topics != null) return false;
        } else {
            if (!this.topics.equals(other.topics)) return false;
        }
        if (this.forgottenTopicsData == null) {
            if (other.forgottenTopicsData != null) return false;
        } else {
            if (!this.forgottenTopicsData.equals(other.forgottenTopicsData)) return false;
        }
        if (this.rackId == null) {
            if (other.rackId != null) return false;
        } else {
            if (!this.rackId.equals(other.rackId)) return false;
        }
        return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields);
    }

    @Override
    public int hashCode() {
        int hashCode = 0;
        hashCode = 31 * hashCode + (clusterId == null ? 0 : clusterId.hashCode());
        hashCode = 31 * hashCode + replicaId;
        hashCode = 31 * hashCode + (replicaState == null ? 0 : replicaState.hashCode());
        hashCode = 31 * hashCode + maxWaitMs;
        hashCode = 31 * hashCode + minBytes;
        hashCode = 31 * hashCode + maxBytes;
        hashCode = 31 * hashCode + isolationLevel;
        hashCode = 31 * hashCode + sessionId;
        hashCode = 31 * hashCode + sessionEpoch;
        hashCode = 31 * hashCode + (topics == null ? 0 : topics.hashCode());
        hashCode = 31 * hashCode + (forgottenTopicsData == null ? 0 : forgottenTopicsData.hashCode());
        hashCode = 31 * hashCode + (rackId == null ? 0 : rackId.hashCode());
        return hashCode;
    }

    @Override
    public FetchRequestData duplicate() {
        FetchRequestData _duplicate = new FetchRequestData();
        _duplicate.clusterId = clusterId;
        _duplicate.replicaId = replicaId;
        _duplicate.replicaState = replicaState;
        _duplicate.maxWaitMs = maxWaitMs;
        _duplicate.minBytes = minBytes;
        _duplicate.maxBytes = maxBytes;
        _duplicate.isolationLevel = isolationLevel;
        _duplicate.sessionId = sessionId;
        _duplicate.sessionEpoch = sessionEpoch;
        FetchTopicCollection newTopics = new FetchTopicCollection(topics.size());
        for (FetchTopic _element : topics) {
            newTopics.add(_element.duplicate());
        }
        _duplicate.topics = newTopics;
        ForgottenTopicCollection newForgottenTopicsData = new ForgottenTopicCollection(forgottenTopicsData.size());
        for (ForgottenTopic _element : forgottenTopicsData) {
            newForgottenTopicsData.add(_element.duplicate());
        }
        _duplicate.forgottenTopicsData = newForgottenTopicsData;
        _duplicate.rackId = rackId;
        return _duplicate;
    }

    @Override
    public String toString() {
        return "FetchRequestData("
            // TODO
            + ")";
    }

    /** 
     * Gets the ClusterId. 
     * The clusterId if known. This is used to validate metadata fetches prior to broker registration.
     * @return the ClusterId.
     */
    public UNKNOWN - ClusterId clusterid() {
        return this.clusterId;
    }
    /** 
     * Gets the ReplicaId. 
     * The broker ID of the follower, of -1 if this request is from a consumer.
     * @return the ReplicaId.
     */
    public int replicaid() {
        return this.replicaId;
    }
    /** 
     * Gets the ReplicaState. 
     * 
     * @return the ReplicaState.
     */
    public UNKNOWN - ReplicaState replicastate() {
        return this.replicaState;
    }
    /** 
     * Gets the MaxWaitMs. 
     * The maximum time in milliseconds to wait for the response.
     * @return the MaxWaitMs.
     */
    public int maxwaitms() {
        return this.maxWaitMs;
    }
    /** 
     * Gets the MinBytes. 
     * The minimum bytes to accumulate in the response.
     * @return the MinBytes.
     */
    public int minbytes() {
        return this.minBytes;
    }
    /** 
     * Gets the MaxBytes. 
     * The maximum bytes to fetch.  See KIP-74 for cases where this limit may not be honored.
     * @return the MaxBytes.
     */
    public int maxbytes() {
        return this.maxBytes;
    }
    /** 
     * Gets the IsolationLevel. 
     * This setting controls the visibility of transactional records. Using READ_UNCOMMITTED (isolation_level = 0) makes all records visible. With READ_COMMITTED (isolation_level = 1), non-transactional and COMMITTED transactional records are visible. To be more concrete, READ_COMMITTED returns all data from offsets smaller than the current LSO (last stable offset), and enables the inclusion of the list of aborted transactions in the result, which allows consumers to discard ABORTED transactional records
     * @return the IsolationLevel.
     */
    public UNKNOWN - IsolationLevel isolationlevel() {
        return this.isolationLevel;
    }
    /** 
     * Gets the SessionId. 
     * The fetch session ID.
     * @return the SessionId.
     */
    public int sessionid() {
        return this.sessionId;
    }
    /** 
     * Gets the SessionEpoch. 
     * The fetch session epoch, which is used for ordering requests in a session.
     * @return the SessionEpoch.
     */
    public int sessionepoch() {
        return this.sessionEpoch;
    }
    /** 
     * Gets the Topics. 
     * The topics to fetch.
     * @return the Topics.
     */
    public FetchTopicCollection topics() {
        return this.topics;
    }
    /** 
     * Gets the ForgottenTopicsData. 
     * In an incremental fetch request, the partitions to remove.
     * @return the ForgottenTopicsData.
     */
    public ForgottenTopicCollection forgottentopicsdata() {
        return this.forgottenTopicsData;
    }
    /** 
     * Gets the RackId. 
     * Rack ID of the consumer making this request
     * @return the RackId.
     */
    public UNKNOWN - RackId rackid() {
        return this.rackId;
    }

    @Override
    public List<RawTaggedField> unknownTaggedFields() {
        if (_unknownTaggedFields == null) {
            _unknownTaggedFields = new ArrayList<>(0);
        }
        return _unknownTaggedFields;
    }

    /** 
     * Sets the ClusterId. 
     * The clusterId if known. This is used to validate metadata fetches prior to broker registration.
     * @param ClusterId the ClusterId.
     */
    public FetchRequestData setClusterId(UNKNOWN - ClusterId clusterId) {
        this.clusterId = clusterId;
        return this;
    }
    /** 
     * Sets the ReplicaId. 
     * The broker ID of the follower, of -1 if this request is from a consumer.
     * @param ReplicaId the ReplicaId.
     */
    public FetchRequestData setReplicaId(int replicaId) {
        this.replicaId = replicaId;
        return this;
    }
    /** 
     * Sets the ReplicaState. 
     * 
     * @param ReplicaState the ReplicaState.
     */
    public FetchRequestData setReplicaState(UNKNOWN - ReplicaState replicaState) {
        this.replicaState = replicaState;
        return this;
    }
    /** 
     * Sets the MaxWaitMs. 
     * The maximum time in milliseconds to wait for the response.
     * @param MaxWaitMs the MaxWaitMs.
     */
    public FetchRequestData setMaxWaitMs(int maxWaitMs) {
        this.maxWaitMs = maxWaitMs;
        return this;
    }
    /** 
     * Sets the MinBytes. 
     * The minimum bytes to accumulate in the response.
     * @param MinBytes the MinBytes.
     */
    public FetchRequestData setMinBytes(int minBytes) {
        this.minBytes = minBytes;
        return this;
    }
    /** 
     * Sets the MaxBytes. 
     * The maximum bytes to fetch.  See KIP-74 for cases where this limit may not be honored.
     * @param MaxBytes the MaxBytes.
     */
    public FetchRequestData setMaxBytes(int maxBytes) {
        this.maxBytes = maxBytes;
        return this;
    }
    /** 
     * Sets the IsolationLevel. 
     * This setting controls the visibility of transactional records. Using READ_UNCOMMITTED (isolation_level = 0) makes all records visible. With READ_COMMITTED (isolation_level = 1), non-transactional and COMMITTED transactional records are visible. To be more concrete, READ_COMMITTED returns all data from offsets smaller than the current LSO (last stable offset), and enables the inclusion of the list of aborted transactions in the result, which allows consumers to discard ABORTED transactional records
     * @param IsolationLevel the IsolationLevel.
     */
    public FetchRequestData setIsolationLevel(UNKNOWN - IsolationLevel isolationLevel) {
        this.isolationLevel = isolationLevel;
        return this;
    }
    /** 
     * Sets the SessionId. 
     * The fetch session ID.
     * @param SessionId the SessionId.
     */
    public FetchRequestData setSessionId(int sessionId) {
        this.sessionId = sessionId;
        return this;
    }
    /** 
     * Sets the SessionEpoch. 
     * The fetch session epoch, which is used for ordering requests in a session.
     * @param SessionEpoch the SessionEpoch.
     */
    public FetchRequestData setSessionEpoch(int sessionEpoch) {
        this.sessionEpoch = sessionEpoch;
        return this;
    }
    /** 
     * Sets the Topics. 
     * The topics to fetch.
     * @param Topics the Topics.
     */
    public FetchRequestData setTopics(FetchTopicCollection topics) {
        this.topics = topics;
        return this;
    }
    /** 
     * Sets the ForgottenTopicsData. 
     * In an incremental fetch request, the partitions to remove.
     * @param ForgottenTopicsData the ForgottenTopicsData.
     */
    public FetchRequestData setForgottenTopicsData(ForgottenTopicCollection forgottenTopicsData) {
        this.forgottenTopicsData = forgottenTopicsData;
        return this;
    }
    /** 
     * Sets the RackId. 
     * Rack ID of the consumer making this request
     * @param RackId the RackId.
     */
    public FetchRequestData setRackId(UNKNOWN - RackId rackId) {
        this.rackId = rackId;
        return this;
    }

    // TODO nested classes

}
