All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dooapp.gaedo.properties.ComparePropertyByNameAndDeclaringClass Maven / Gradle / Ivy

package com.dooapp.gaedo.properties;

import java.util.Comparator;

/**
 * Compare properties based upon fields they all declare.
 * This comparator should not support by any way having two properties that are equals.
 * @author ndx
 *
 */
public class ComparePropertyByNameAndDeclaringClass implements Comparator {

	@Override
	public int compare(Property o1, Property o2) {
		int result = o1.getName().compareTo(o2.getName());
		if(result!=0)
			return result;
		result = o1.getDeclaringClass().getName().compareTo(o2.getDeclaringClass().getName());
		if(result!=0)
			return result;
		result = o1.getGenericType().toString().compareTo(o2.getGenericType().toString());
		return result;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy