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

io.tracee.contextlogger.impl.MethodAnnotationPairComparator Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
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;
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy