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

com.volcengine.util.NameValueComparator Maven / Gradle / Ivy

There is a newer version: 1.0.192
Show newest version
package com.volcengine.util;

import org.apache.http.NameValuePair;

import java.util.Comparator;




public enum  NameValueComparator implements Comparator {
    INSTANCE;

    private final static boolean NULL_FIRST = false;

    @Override
    public int compare(NameValuePair o1, NameValuePair o2) {
        if (o1.getName() == null) {
            return (o2.getName() == null) ? 0 : (NULL_FIRST ? -1 : 1);
        } else if (o2.getName() == null) {
            return NULL_FIRST ? 1: -1;
        } else {
            return o1.getName().compareTo(o2.getName());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy