/*
 * Copyright (c) 2011, Patrik Dufresne. All rights reserved.
 * Patrik Dufresne PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.planimod.core.comparators;

import java.util.Comparator;

import org.apache.commons.collections.ComparatorUtils;
import org.apache.commons.collections.Transformer;

import com.planimod.core.Section;

/**
 * Provie comparator for section object.
 * 
 * @author Patrik Dufresne
 * 
 */
public class SectionComparators {

	/**
	 * Comparator to sort section by name.
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static Comparator<Section> byName() {
		return ComparatorUtils.nullHighComparator(ComparatorUtils
				.transformedComparator(ComparatorUtils
						.nullHighComparator(new HumanNaturalComparator()),
						new Transformer() {
							@Override
							public Object transform(Object arg0) {
								return ((Section) arg0).getName();
							}
						}));
	}

}
