view src/main/java/de/mpiwg/web/books/SortBooksByDate.java @ 16:a7e9c1f8edb4

new: sorting in books page, adding books package
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 01 Jun 2015 14:40:48 +0200
parents
children
line wrap: on
line source

package de.mpiwg.web.books;

import java.util.Comparator;


import de.mpiwg.gazetteer.db.DBBook;


public class SortBooksByDate implements Comparator<DBBook>{
	
	public int compare(DBBook o1, DBBook o2) {
		
		if(o1.getCurrentSectionVersion() == null && o2.getCurrentSectionVersion() == null) {
			return o1.getId().compareTo(o2.getId());	
		} else if (o1.getCurrentSectionVersion() == null) {
			return -1;
		} else if (o2.getCurrentSectionVersion() == null){
			return 1;
		} else {
			return o1.getCurrentSectionVersion().getDate().compareTo(o2.getCurrentSectionVersion().getDate());	
		}
	
	}

}