Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.apache.maven.plugin.changelog;
  
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 
 
 import java.util.List;

Object used to sort the file-activity report into descending order.

Version:
$Id: FileActivityComparator.java 1517983 2013-08-27 20:57:20Z krosenvold $
 
 public class FileActivityComparator
     implements Comparator<List<ChangeFile>>
 {
    
 
     public int compareList<ChangeFilelist1List<ChangeFilelist2 )
         throws ClassCastException
     {
         int returnValue = sortByCommitslist1list2 );
 
         if ( returnValue != 0 )
         {
             return returnValue;
         }
 
         returnValue = sortByRevisionlist1list2 );
 
         if ( returnValue != 0 )
         {
             return returnValue;
         }
 
         return sortByNamelist1list2 );
     }

    
compares list1 and list2 by the number of commits

Parameters:
list1 the first object in a compare statement
list2 the object to compare list1 against
Returns:
an integer describing the order comparison of list1 and list2
 
     private int sortByCommitsList<ChangeFilelist1List<ChangeFilelist2 )
     {
         if ( list1.size() > list2.size() )
         {
             return -1;
         }
 
         if ( list1.size() < list2.size() )
         {
             return 1;
         }
 
         return 0;
     }

    
compares list1 and list2 by comparing their revision code

Parameters:
list1 the first object in a compare statement
list2 the object to compare list1 against
Returns:
an integer describing the order comparison of list1 and list2
 
     private int sortByRevisionList<ChangeFilelist1List<ChangeFilelist2 )
     {
         String revision1 = getLatestRevisionlist1 );
 
         String revision2 = getLatestRevisionlist2 );
 
         if ( revision1 == null )
         {
             return -1;
         }
 
         if ( revision2 == null )
        {
            return 1;
        }
        return revision1.compareTorevision2 );
    }

    
retrieves the latest revision from the commits made from the SCM

Parameters:
list The list of revisions from the file
Returns:
the latest revision code
    private String getLatestRevisionList<ChangeFilelist )
    {
        String latest = "";
        for ( ChangeFile file : list )
        {
            if ( StringUtils.isNotBlanklatest ) )
            {
                latest = file.getRevision();
            }
            else if ( latest.compareTofile.getRevision() ) < 0 )
            {
                latest = file.getRevision();
            }
        }
        return latest;
    }

    
compares list1 and list2 by comparing their filenames. Least priority sorting when both number of commits and and revision are the same

Parameters:
list1 the first object in a compare statement
list2 the object to compare list1 against
Returns:
an integer describing the order comparison of list1 and list2
    private int sortByNameList<ChangeFilelist1List<ChangeFilelist2 )
    {
        ChangeFile file1 = list1.get( 0 );
        ChangeFile file2 = list2.get( 0 );
        return file1.getName().compareTofile2.getName() );
    }
New to GrepCode? Check out our FAQ X