io.tracee.contextlogger.impl.MethodAnnotationPairComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of contextlogger-core Show documentation
Show all versions of contextlogger-core Show documentation
Please refer to https://github.com/tracee/contextlogger.
package io.tracee.contextlogger.impl;
import java.util.Comparator;
/**
* Comparator to sort {@link MethodAnnotationPair} instances.
* Created by Tobias Gindler, holisticon AG on 14.03.14.
*/
public final class MethodAnnotationPairComparator implements Comparator {
@Override
public int compare(MethodAnnotationPair instance1, MethodAnnotationPair instance2) {
// primary sort criteria is the order value of the annotation
if (instance1 == null && instance2 == null) {
return 0;
} else if (instance1 != null && instance2 == null) {
return 1;
} else if (instance1 == null) {
return -1;
} else {
int result = Integer.valueOf(instance1.getAnnotation().order()).compareTo(instance2.getAnnotation().order());
if (result == 0) {
result = instance1.getAnnotation().displayName().compareTo(instance2.getAnnotation().displayName());
}
return result;
}
}
}