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

com.maxifier.mxcache.jconsoleplugin.ComparableComparator Maven / Gradle / Ivy

There is a newer version: 2.6.9
Show newest version
/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.jconsoleplugin;

import java.io.Serializable;
import java.util.Comparator;

/**
 * @author Alexander Kochurov ([email protected])
 */
public class ComparableComparator implements Comparator, Serializable {
    private static final long serialVersionUID = 1L;

    @SuppressWarnings({ "unchecked" })
    @Override
    public int compare(Comparable o1, Comparable o2) {
        if (o1 == null) {
            return o2 == null ? -1 : 0;
        }
        if (o2 == null) {
            return 1;
        }
        return o1.compareTo(o2);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy