View Javadoc

1   package ca.uhn.hl7v2.testpanel.util;
2   
3   import java.io.File;
4   import java.util.Comparator;
5   
6   /**
7    * Comparator which sorts by file name
8    */
9   public class FileNameComparator implements Comparator<File> {
10  
11  	/**
12  	 * {@inheritDoc}
13  	 */
14  	@Override
15  	public int compare(File theO1, File theO2) {
16  		if (theO1 == null && theO2 == null) {
17  			return 0;
18  		}
19  		
20  		if (theO1 == null) {
21  			return -1;
22  		}
23  		
24  		if (theO2 == null) {
25  			return 1;
26  		}
27  		
28  		return theO1.getName().compareTo(theO2.getName());
29  	}
30  
31  }