    001    // Copyright 2008, 2010 The Apache Software Foundation
    002    //
    003    // Licensed under the Apache License, Version 2.0 (the "License");
    004    // you may not use this file except in compliance with the License.
    005    // You may obtain a copy of the License at
    006    //
    007    //     http://www.apache.org/licenses/LICENSE-2.0
    008    //
    009    // Unless required by applicable law or agreed to in writing, software
    010    // distributed under the License is distributed on an "AS IS" BASIS,
    011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012    // See the License for the specific language governing permissions and
    013    // limitations under the License.
    014
    015    package org.apache.tapestry5.grid;
    016
    017    import org.apache.tapestry5.beaneditor.PropertyModel;
    018
    019    /**
    020     * Identifies how a single column (identified as a {@link org.apache.tapestry5.beaneditor.PropertyModel}) is sorted.
    021     */
    022    public class SortConstraint
    023    {
    024        private final PropertyModel propertyModel;
    025
    026        private final ColumnSort columnSort;
    027
    028        public SortConstraint(PropertyModel propertyModel, ColumnSort columnSort)
    029        {
    030            assert propertyModel != null;
    031            assert columnSort != null;
    032
    033            this.propertyModel = propertyModel;
    034            this.columnSort = columnSort;
    035        }
    036
    037        public PropertyModel getPropertyModel()
    038        {
    039            return propertyModel;
    040        }
    041
    042        public ColumnSort getColumnSort()
    043        {
    044            return columnSort;
    045        }
    046
    047        // equals() is useful for testing
    048
    049        @Override
    050        public boolean equals(Object o)
    051        {
    052            if (this == o) return true;
    053
    054            if (o == null || getClass() != o.getClass()) return false;
    055
    056            SortConstraint that = (SortConstraint) o;
    057
    058            if (columnSort != that.columnSort) return false;
    059
    060            return propertyModel.equals(that.propertyModel);
    061        }
    062    }