001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.extensions.markup.html.repeater.data.table;
018
019import org.apache.wicket.Component;
020import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
021
022
023/**
024 * An interface that represents a column in the {@link DefaultDataTable}
025 * 
026 * @author Igor Vaynberg ( ivaynberg )
027 * @param <T>
028 *     the type of the object that will be rendered in this column's cells
029 * @param <S>
030 *     the type of the sorting parameter
031 */
032public interface IColumn<T, S> extends ICellPopulator<T>
033{
034        /**
035         * Returns the component that will be used as the header for the column.
036         * 
037         * This component will be contained in &lt;span&gt; tags.
038         * 
039         * @param componentId
040         *            component id for the returned Component
041         * 
042         * @return component that will be used as the header for the column
043         */
044        Component getHeader(String componentId);
045
046        /**
047         * Returns the property that this header sorts on.
048         * If {@code null} is returned the header will be not sortable.
049         * 
050         * @return the sort property
051         */
052        S getSortProperty();
053
054        /**
055         * Returns true if the header of the column should be sortable
056         * 
057         * @return true if header should be sortable
058         */
059        default boolean isSortable()
060        {
061                return getSortProperty() != null;
062        }
063
064        /**
065         * @return The number of rows the header of this column should span
066         */
067        default int getHeaderRowspan() {
068                return 1;
069        }
070
071        /**
072         * @return The number of columns the header of this column should span
073         */
074        default int getHeaderColspan() {
075                return 1;
076        }
077}