All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.larmic.butterfaces.model.table.DefaultTableSortModel Maven / Gradle / Ivy

package de.larmic.butterfaces.model.table;

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

/**
 * Created by larmic on 03.12.14.
 */
public class DefaultTableSortModel implements TableSortModel {

    /**
     * Map of column id and {@link de.larmic.butterfaces.model.table.SortType} information.
     */
    private final Map columnSortTypes = new HashMap<>();

    /**
     * Resets all sort orders to NONE and sets {@link de.larmic.butterfaces.model.table.SortType} for corresponding column id.
     *
     * @param columnId optional column id (generated id will be used is column id attribute is not set)
     * @param sortBy   optional column component attribute
     * @param sortType the {@link de.larmic.butterfaces.model.table.SortType}
     */
    @Override
    public void sortColumn(final String columnId, final String sortBy, final SortType sortType) {
        for (String key : columnSortTypes.keySet()) {
            columnSortTypes.put(key, SortType.NONE);
        }

        columnSortTypes.put(columnId, sortType);
    }

    @Override
    public SortType getSortType(final String columnClientId) {
        return columnSortTypes.get(columnClientId);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy