package de.codecrafters.tableview.model;

import java.util.HashMap;
import java.util.Map;


/**
 * A {@link TableColumnModel} implementation holding absolute column widths.
 *
 * @author ISchwarz
 */
@Deprecated
public class TableColumnWidthModel implements TableColumnModel {

    private static final int DEFAULT_COLUMN_WIDTH = 200;

    private final Map<Integer, Integer> columnWidths;
    private int columnCount;
    private int defaultColumnWidth;

    /**
     * Creates a new TableColumnModel with the given number of columns. Every column has by default
     * a width of 200px.
     *
     * @param columnCount The number of columns.
     */
    public TableColumnWidthModel(final int columnCount) {
        this(columnCount, DEFAULT_COLUMN_WIDTH);
    }

    /**
     * Creates a new TableColumnModel with the given number of columns. Every column has the given default width.
     *
     * @param columnCount The number of columns.
     */
    public TableColumnWidthModel(final int columnCount, final int defaultColumnWidth) {
        this.columnWidths = new HashMap<>();
        this.columnCount = columnCount;
        this.defaultColumnWidth = defaultColumnWidth;
    }

    /**
     * Sets the column width for the column at the given index.
     *
     * @param columnIndex The index of the column.
     * @param columnWidth The width of the column.
     */
    public void setColumnWidth(int columnIndex, int columnWidth) {
        this.columnWidths.put(columnIndex, columnWidth);
    }

    @Override
    public void setColumnCount(final int columnCount) {
        this.columnCount = columnCount;
    }

    @Override
    public int getColumnCount() {
        return columnCount;
    }

    @Override
    public int getColumnWidth(int columnIndex, int tableWidthInPx) {
        final Integer columnWidth = columnWidths.get(columnIndex);
        if (columnWidth == null) {
            return defaultColumnWidth;
        }
        return columnWidth;
    }
}

@@ -199,16 +199,130 @@
 chwarz%0D%0A
+ * @deprecated This class has been deprecated in version 2.4.1. Use the %7B@link TableColumnPxWidthModel%7D instead.%0D%0A
  */%0D%0A@De

Add deprecation doc to TableColumnWidthModel