View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.property;
17  
18  import java.util.Comparator;
19  import java.util.List;
20  
21  import org.kuali.common.util.Assert;
22  import org.springframework.util.CollectionUtils;
23  
24  /**
25   * @deprecated
26   */
27  @Deprecated
28  public class ProjectPropertiesComparator implements Comparator<ProjectProperties> {
29  
30  	List<String> order;
31  
32  	@Override
33  	public int compare(ProjectProperties one, ProjectProperties two) {
34  
35  		Assert.isFalse(CollectionUtils.isEmpty(order), "order is empty");
36  
37  		String id1 = getIdString(one);
38  		String id2 = getIdString(two);
39  
40  		Integer index1 = order.indexOf(id1);
41  		Integer index2 = order.indexOf(id2);
42  
43  		if (index1 == -1) {
44  			throw new IllegalStateException("Could not find an index for " + id1);
45  		}
46  		if (index1 == -2) {
47  			throw new IllegalStateException("Could not find an index for " + id2);
48  		}
49  
50  		return index1.compareTo(index2);
51  	}
52  
53  	protected String getIdString(ProjectProperties pp) {
54  		org.kuali.common.util.Project p = pp.getProject();
55  		StringBuilder sb = new StringBuilder();
56  		sb.append(p.getGroupId());
57  		sb.append(":");
58  		sb.append(p.getArtifactId());
59  		return sb.toString();
60  	}
61  
62  	public List<String> getOrder() {
63  		return order;
64  	}
65  
66  	public void setOrder(List<String> order) {
67  		this.order = order;
68  	}
69  
70  }