package com.cesgroup.cesmonitor.screenbean;

import java.io.Serializable;

/**
 * @author user
 * @version 1.0.0 2017年5月10日
 */
public class CpuScreen implements Serializable, Comparable<CpuScreen> {

    private static final long serialVersionUID = 3069197370518325658L;

    private String hostName;

    private Double cpuRate;

    public CpuScreen() {
        super();
    }

    /**
     * 构造方法
     */
    public CpuScreen(String hostName, Double cpuRate) {
        super();
        this.hostName = hostName;
        this.cpuRate = cpuRate;
    }

    public Double getCpuRate() {
        return cpuRate;
    }

    public void setCpuRate(Double cpuRate) {
        this.cpuRate = cpuRate;
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    @Override
    public int compareTo(CpuScreen cpu) {
        if (this == cpu) {
            return 0;
        } else if (cpu != null && cpu instanceof CpuScreen) {
            CpuScreen c = cpu;
            if (this.cpuRate < c.cpuRate) {
                return -1;
            } else if (this.cpuRate > c.cpuRate) {
                return 1;
            } else {
                return 0;
            }
        } else {
            return -1;
        }
    }
}
