001 // Copyright 2008 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 import org.apache.tapestry5.ioc.internal.util.Defense;
019
020 /**
021 * Identifies how a single column (identified as a {@link org.apache.tapestry5.beaneditor.PropertyModel}) is sorted.
022 */
023 public class SortConstraint
024 {
025 private final PropertyModel propertyModel;
026
027 private final ColumnSort columnSort;
028
029 public SortConstraint(PropertyModel propertyModel, ColumnSort columnSort)
030 {
031 Defense.notNull(propertyModel, "propertyModel");
032 Defense.notNull(columnSort, "columnSort");
033
034 this.propertyModel = propertyModel;
035 this.columnSort = columnSort;
036 }
037
038 public PropertyModel getPropertyModel()
039 {
040 return propertyModel;
041 }
042
043 public ColumnSort getColumnSort()
044 {
045 return columnSort;
046 }
047
048 // equals() is useful for testing
049
050 @Override
051 public boolean equals(Object o)
052 {
053 if (this == o) return true;
054
055 if (o == null || getClass() != o.getClass()) return false;
056
057 SortConstraint that = (SortConstraint) o;
058
059 if (columnSort != that.columnSort) return false;
060
061 return propertyModel.equals(that.propertyModel);
062 }
063 }