1 package org.codehaus.redback.integration.util;
4 * Copyright 2005-2006 The Codehaus.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.util.Comparator;
21 import org.codehaus.plexus.redback.rbac.TemplatedRole;
26 * @author <a href="hisidro@exist.com">Henry Isidro</a>
29 public class TemplatedRoleSorter
30 implements Comparator<TemplatedRole>
32 public int compare( TemplatedRole r1, TemplatedRole r2 )
34 if ( ( r1 == null ) && ( r2 == null ) )
39 if ( ( r1 == null ) && ( r2 != null ) )
44 if ( ( r1 != null ) && ( r2 == null ) )
49 if ( r1.getResource().equals( r2.getResource() ) )
51 return r1.getTemplateNamePrefix().compareTo( r2.getTemplateNamePrefix() );
55 return r1.getResource().compareToIgnoreCase( r2.getResource() );