// Path: src/main/java/com/google/cloud/spanner/pgadapter/metadata/DescribeMetadata.java
// public abstract class DescribeMetadata<T> {
// 
//   protected T metadata;
// 
//   public T getMetadata() {
//     return this.metadata;
//   }
// }
// 
// Path: src/main/java/com/google/cloud/spanner/pgadapter/metadata/DescribePortalMetadata.java
// public class DescribePortalMetadata extends DescribeMetadata<ResultSetMetaData> {
// 
//   public DescribePortalMetadata(ResultSetMetaData metadata) {
//     this.metadata = metadata;
//   }
// }


import com.google.cloud.spanner.pgadapter.metadata.DescribeMetadata;
import com.google.cloud.spanner.pgadapter.metadata.DescribePortalMetadata;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
  public short getParameterFormatCode(int index) {
    if (this.parameterFormatCodes.size() == 0) {
      return 0;
    } else if (this.parameterFormatCodes.size() == 1) {
      return this.parameterFormatCodes.get(0);
    } else {
      return this.parameterFormatCodes.get(index - 1);
    }
  }

  @Override
  public short getResultFormatCode(int index) {
    if (this.resultFormatCodes == null || this.resultFormatCodes.isEmpty()) {
      return 0;
    } else if (this.resultFormatCodes.size() == 1) {
      return this.resultFormatCodes.get(0);
    } else {
      return this.resultFormatCodes.get(index - 1);
    }
  }

  public void setParameterFormatCodes(List<Short> parameterFormatCodes) {
    this.parameterFormatCodes = parameterFormatCodes;
  }

  public void setResultFormatCodes(List<Short> resultFormatCodes) {
    this.resultFormatCodes = resultFormatCodes;
  }

  @Override
// Path: src/main/java/com/google/cloud/spanner/pgadapter/metadata/DescribeMetadata.java
// public abstract class DescribeMetadata<T> {
// 
//   protected T metadata;
// 
//   public T getMetadata() {
//     return this.metadata;
//   }
// }
// 
// Path: src/main/java/com/google/cloud/spanner/pgadapter/metadata/DescribePortalMetadata.java
// public class DescribePortalMetadata extends DescribeMetadata<ResultSetMetaData> {
// 
//   public DescribePortalMetadata(ResultSetMetaData metadata) {
//     this.metadata = metadata;
//   }
// }


// Path: src/main/java/com/google/cloud/spanner/pgadapter/statements/IntermediatePortalStatement.java
import com.google.cloud.spanner.pgadapter.metadata.DescribeMetadata;
import com.google.cloud.spanner.pgadapter.metadata.DescribePortalMetadata;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

  public short getParameterFormatCode(int index) {
    if (this.parameterFormatCodes.size() == 0) {
      return 0;
    } else if (this.parameterFormatCodes.size() == 1) {
      return this.parameterFormatCodes.get(0);
    } else {
      return this.parameterFormatCodes.get(index - 1);
    }
  }

  @Override
  public short getResultFormatCode(int index) {
    if (this.resultFormatCodes == null || this.resultFormatCodes.isEmpty()) {
      return 0;
    } else if (this.resultFormatCodes.size() == 1) {
      return this.resultFormatCodes.get(0);
    } else {
      return this.resultFormatCodes.get(index - 1);
    }
  }

  public void setParameterFormatCodes(List<Short> parameterFormatCodes) {
    this.parameterFormatCodes = parameterFormatCodes;
  }

  public void setResultFormatCodes(List<Short> resultFormatCodes) {
    this.resultFormatCodes = resultFormatCodes;
  }

  @Override
  public DescribeMetadata describe() throws Exception {