// Path: src/main/java/kafka/common/ErrorMapping.java
// public abstract class ErrorMapping {
//     public static final ByteBuffer EmptyByteBuffer = ByteBuffer.allocate(0);
// 
//     public static final short UnknownCode = -1;
//     public static final short NoError = 0;
//     public static final short OffsetOutOfRangeCode = 1;
//     public static final short InvalidMessageCode = 2;
//     public static final short UnknownTopicOrPartitionCode = 3;
//     public static final short InvalidFetchSizeCode = 4;
//     public static final short LeaderNotAvailableCode = 5;
//     public static final short NotLeaderForPartitionCode = 6;
//     public static final short RequestTimedOutCode = 7;
//     public static final short BrokerNotAvailableCode = 8;
//     public static final short ReplicaNotAvailableCode = 9;
//     public static final short MessageSizeTooLargeCode = 10;
//     public static final short StaleControllerEpochCode = 11;
//     public static final short OffsetMetadataTooLargeCode = 12;
//     public static final short StaleLeaderEpochCode = 13;
// 
//     private static BiMap<Class<? extends Throwable>, Short> exceptionToCode;
// 
//     static {
//         exceptionToCode.put(OffsetOutOfRangeException.class, OffsetOutOfRangeCode);
//         exceptionToCode.put(InvalidMessageException.class, InvalidMessageCode);
//         exceptionToCode.put(UnknownTopicOrPartitionException.class, UnknownTopicOrPartitionCode);
//         exceptionToCode.put(InvalidMessageSizeException.class, InvalidFetchSizeCode);
//         exceptionToCode.put(NotLeaderForPartitionException.class, NotLeaderForPartitionCode);
//         exceptionToCode.put(LeaderNotAvailableException.class, LeaderNotAvailableCode);
//         exceptionToCode.put(RequestTimedOutException.class, RequestTimedOutCode);
//         exceptionToCode.put(BrokerNotAvailableException.class, BrokerNotAvailableCode);
//         exceptionToCode.put(ReplicaNotAvailableException.class, ReplicaNotAvailableCode);
//         exceptionToCode.put(MessageSizeTooLargeException.class, MessageSizeTooLargeCode);
//         exceptionToCode.put(ControllerMovedException.class, StaleControllerEpochCode);
//         exceptionToCode.put(OffsetMetadataTooLargeException.class, OffsetMetadataTooLargeCode);
//     }
// 
//     public static Short codeFor(Class<? extends Throwable> exception) {
//         return Objects.firstNonNull(exceptionToCode.get(exception), UnknownCode);
//     }
// 
//     public static void maybeThrowException(Short code) {
//         Throwable throwable = exceptionFor(code);
//         if (throwable != null) {
//             throw Throwables.propagate(throwable);
//         }
//     }
// 
//     static Logger logger = LoggerFactory.getLogger(ErrorMapping.class);
// 
//     public static KafkaException exceptionFor(Short code) {
//         Class<? extends Throwable> throwable = exceptionToCode.inverse().get(code);
//         if (throwable == null) return null;
// 
//         try {
//             return (KafkaException) throwable.newInstance();
//         } catch (Exception e) {
//             logger.error("create instance of {} error", throwable, e);
//         }
//         return null;
//     }
// }


import kafka.common.ErrorMapping;
import kafka.utils.*;
import java.nio.ByteBuffer;
import java.util.Map;
import static kafka.api.ApiUtils.readShortString;
import static kafka.api.ApiUtils.writeShortString;
package kafka.api;




public class LeaderAndIsrResponse extends RequestOrResponse {
    public static LeaderAndIsrResponse readFrom(final ByteBuffer buffer) {
        int correlationId = buffer.getInt();
        short errorCode = buffer.getShort();
        int numEntries = buffer.getInt();
        Map<Tuple2<String, Integer>, Short> responseMap = Utils.flatMap(0, numEntries, new Function0<Tuple2<Tuple2<String, Integer>, Short>>() {
            @Override
            public Tuple2<Tuple2<String, Integer>, Short> apply() {
                String topic = readShortString(buffer);
                int partition = buffer.getInt();
                short partitionErrorCode = buffer.getShort();
                return Tuple2.make(Tuple2.make(topic, partition), partitionErrorCode);
            }
        });

        return new LeaderAndIsrResponse(correlationId, responseMap, errorCode);
    }

    public Map<Tuple2<String, Integer>, Short> responseMap;
    public short errorCode;

    public LeaderAndIsrResponse(int correlationId, Map<Tuple2<String, Integer>, Short> responseMap) {
// Path: src/main/java/kafka/common/ErrorMapping.java
// public abstract class ErrorMapping {
//     public static final ByteBuffer EmptyByteBuffer = ByteBuffer.allocate(0);
// 
//     public static final short UnknownCode = -1;
//     public static final short NoError = 0;
//     public static final short OffsetOutOfRangeCode = 1;
//     public static final short InvalidMessageCode = 2;
//     public static final short UnknownTopicOrPartitionCode = 3;
//     public static final short InvalidFetchSizeCode = 4;
//     public static final short LeaderNotAvailableCode = 5;
//     public static final short NotLeaderForPartitionCode = 6;
//     public static final short RequestTimedOutCode = 7;
//     public static final short BrokerNotAvailableCode = 8;
//     public static final short ReplicaNotAvailableCode = 9;
//     public static final short MessageSizeTooLargeCode = 10;
//     public static final short StaleControllerEpochCode = 11;
//     public static final short OffsetMetadataTooLargeCode = 12;
//     public static final short StaleLeaderEpochCode = 13;
// 
//     private static BiMap<Class<? extends Throwable>, Short> exceptionToCode;
// 
//     static {
//         exceptionToCode.put(OffsetOutOfRangeException.class, OffsetOutOfRangeCode);
//         exceptionToCode.put(InvalidMessageException.class, InvalidMessageCode);
//         exceptionToCode.put(UnknownTopicOrPartitionException.class, UnknownTopicOrPartitionCode);
//         exceptionToCode.put(InvalidMessageSizeException.class, InvalidFetchSizeCode);
//         exceptionToCode.put(NotLeaderForPartitionException.class, NotLeaderForPartitionCode);
//         exceptionToCode.put(LeaderNotAvailableException.class, LeaderNotAvailableCode);
//         exceptionToCode.put(RequestTimedOutException.class, RequestTimedOutCode);
//         exceptionToCode.put(BrokerNotAvailableException.class, BrokerNotAvailableCode);
//         exceptionToCode.put(ReplicaNotAvailableException.class, ReplicaNotAvailableCode);
//         exceptionToCode.put(MessageSizeTooLargeException.class, MessageSizeTooLargeCode);
//         exceptionToCode.put(ControllerMovedException.class, StaleControllerEpochCode);
//         exceptionToCode.put(OffsetMetadataTooLargeException.class, OffsetMetadataTooLargeCode);
//     }
// 
//     public static Short codeFor(Class<? extends Throwable> exception) {
//         return Objects.firstNonNull(exceptionToCode.get(exception), UnknownCode);
//     }
// 
//     public static void maybeThrowException(Short code) {
//         Throwable throwable = exceptionFor(code);
//         if (throwable != null) {
//             throw Throwables.propagate(throwable);
//         }
//     }
// 
//     static Logger logger = LoggerFactory.getLogger(ErrorMapping.class);
// 
//     public static KafkaException exceptionFor(Short code) {
//         Class<? extends Throwable> throwable = exceptionToCode.inverse().get(code);
//         if (throwable == null) return null;
// 
//         try {
//             return (KafkaException) throwable.newInstance();
//         } catch (Exception e) {
//             logger.error("create instance of {} error", throwable, e);
//         }
//         return null;
//     }
// }


// Path: src/main/java/kafka/api/LeaderAndIsrResponse.java
import kafka.common.ErrorMapping;
import kafka.utils.*;
import java.nio.ByteBuffer;
import java.util.Map;
import static kafka.api.ApiUtils.readShortString;
import static kafka.api.ApiUtils.writeShortString;

package kafka.api;




public class LeaderAndIsrResponse extends RequestOrResponse {
    public static LeaderAndIsrResponse readFrom(final ByteBuffer buffer) {
        int correlationId = buffer.getInt();
        short errorCode = buffer.getShort();
        int numEntries = buffer.getInt();
        Map<Tuple2<String, Integer>, Short> responseMap = Utils.flatMap(0, numEntries, new Function0<Tuple2<Tuple2<String, Integer>, Short>>() {
            @Override
            public Tuple2<Tuple2<String, Integer>, Short> apply() {
                String topic = readShortString(buffer);
                int partition = buffer.getInt();
                short partitionErrorCode = buffer.getShort();
                return Tuple2.make(Tuple2.make(topic, partition), partitionErrorCode);
            }
        });

        return new LeaderAndIsrResponse(correlationId, responseMap, errorCode);
    }

    public Map<Tuple2<String, Integer>, Short> responseMap;
    public short errorCode;

    public LeaderAndIsrResponse(int correlationId, Map<Tuple2<String, Integer>, Short> responseMap) {
        this(correlationId, responseMap, ErrorMapping.NoError);