/**
* @author pplitzner
* @date Apr 13, 2016
- *
*/
public class SourceComparator <T extends OriginalSourceBase> implements Comparator<T> {
+
@Override
public int compare(T o1, T o2) {
- int id1 = o1.getId();
- int id2 = o2.getId();
+
+ //same and null compare, to be on the save side
+ if (o1 == o2){
+ return 0;
+ }else if (o1 == null){
+ return -1;
+ }else if (o2 == null){
+ return 1;
+ }
+
boolean isDescriptionElementSource1 = false;
boolean isDescriptionElementSource2 = false;
- if (o1 instanceof DescriptionElementSource){
+ if (o1.isInstanceOf(DescriptionElementSource.class)){
isDescriptionElementSource1 = true;
}
- if (o2 instanceof DescriptionElementSource){
+ if (o2.isInstanceOf(DescriptionElementSource.class)){
isDescriptionElementSource2 = true;
}
+ int result = 0;
if (isDescriptionElementSource1 != isDescriptionElementSource2){
if (isDescriptionElementSource1){
return -1;