package de.codecrafters.sortabletableview;

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

/**
 * A model holding the column information of a {@link TableView}.
 * Such column information is the relative column width (alias ColumnWeight) and the number of columns
 * (alias ColumnCount).
 *
 * @author ISchwarz
 */
public class TableColumnModel {

    private static final int DEFAULT_COLUMN_WEIGHT = 1;

    private final Map<Integer, Integer> columnWeights;
    private int columnCount;

    public TableColumnModel(int columnCount) {
        this.columnWeights = new HashMap<>();
        this.columnCount = columnCount;
    }

    public int getColumnCount() {
        return columnCount;
    }

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

    public void setColumnWeight(int columnIndex, int columnWeight) {
        columnWeights.put(columnIndex, columnWeight);
    }

    public int getColumnWeight(int columnIndex) {
        Integer columnWeight = columnWeights.get(columnIndex);
        if(columnWeight == null) {
            columnWeight = DEFAULT_COLUMN_WEIGHT;
        }
        return columnWeight;
    }

    public int getColumnWeightSum() {
        int weightSum = 0;

        for(int columnIndex=0; columnIndex<columnCount; columnIndex++) {
            weightSum += getColumnWeight(columnIndex);
        }

        return weightSum;
    }

}

@@ -91,16 +91,18 @@
 Map;%0D%0A%0D%0A
+%0D%0A
 /**%0D%0A * 
@@ -502,24 +502,233 @@
 mnCount;%0D%0A%0D%0A
+    /**%0D%0A     * Creates a new TableColumnModel with the given number of columns. Every column has by default%0D%0A     * a weight (relative width) of 1.%0D%0A     * @param columnCount The number of columns.%0D%0A     */%0D%0A
     public T
@@ -852,32 +852,163 @@
 ount;%0D%0A    %7D%0D%0A%0D%0A
+    /**%0D%0A     * Sets the column count to this model.%0D%0A     * @param columnCount The number of columns that shall be set.%0D%0A     */%0D%0A
     public int g
@@ -994,37 +994,38 @@
  */%0D%0A    public 
-int g
+void s
 etColumnCount() 
@@ -1026,49 +1026,201 @@
 unt(
-) %7B%0D%0A        return columnCount;%0D%0A    %7D%0D%0A
+int columnCount) %7B%0D%0A        this.columnCount = columnCount;%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Gives the column count of this model.%0D%0A     * @return The number of columns that is currently set.%0D%0A     */
 %0D%0A  
@@ -1220,38 +1220,37 @@
  */%0D%0A    public 
-void s
+int g
 etColumnCount(in
@@ -1251,76 +1251,349 @@
 unt(
-int columnCount) %7B%0D%0A        this.columnCount = columnCount;
+) %7B%0D%0A        return columnCount;%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Sets the column weight (the relative width of a column) of the column at the given index.%0D%0A     * @param columnIndex The index of the column to which this weight should be assigned.
 %0D%0A    
+ 
-%7D%0D%0A
+* @param columnWeight The weight that should be set to the column at the given index.%0D%0A     */
 %0D%0A  
@@ -1716,32 +1716,298 @@
 ght);%0D%0A    %7D%0D%0A%0D%0A
+    /**%0D%0A     * Gives the column weight (the relative width of a column) of the column at the given index.%0D%0A     * @param columnIndex The index of the column to receive the column weight.%0D%0A     * @return The column weight of the column at the given index.%0D%0A     */%0D%0A
     public int g
@@ -2238,24 +2238,151 @@
 ;%0D%0A    %7D%0D%0A%0D%0A
+    /**%0D%0A     * Gives the overall column weight (sum of all column weights).%0D%0A     * @return The collumn weight sum.%0D%0A     */%0D%0A
     public i

Fix JavaDoc TableColumnModel