package com.bocloud.ims.service.engine;

import com.bocloud.ims.entity.resource.DataStore;

import java.util.Comparator;

/**
 * 数据存储空闲空间比较器(升序)
 *
 * @author sxp
 * @since 2023/9/18
 */
public class DataStoreFreeSpaceComparator implements Comparator<DataStore> {
    public DataStoreFreeSpaceComparator() {
    }

    public int compare(DataStore ds1, DataStore ds2) {
        Long freeSpace1 = ds1.getFreeSpace();
        Long freeSpace2 = ds2.getFreeSpace();
        if (freeSpace1 == null) {
            freeSpace1 = 0L;
        }
        if (freeSpace2 == null) {
            freeSpace2 = 0L;
        }

        return freeSpace1.compareTo(freeSpace2);
    }
}
