package com.cesgroup.cesmonitor.bean;

import java.io.Serializable;

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

    private static final long serialVersionUID = 3069197370518325658L;

    private String hostName;

    private String hostId;

    private double cpuRate;

    public Cpu() {
        super();
    }

    /**
     * 构造方法
     */
    public Cpu(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(Cpu cpu) {
        if (this == cpu) {
            return 0;
        } else if (cpu != null && cpu instanceof Cpu) {
            Cpu c = cpu;
            if (this.cpuRate < c.cpuRate) {
                return -1;
            } else if (this.cpuRate > c.cpuRate) {
                return 1;
            } else {
                return 0;
            }
        } else {
            return -1;
        }
    }

    /**
     * @return the hostId
     */
    public String getHostId() {
        return hostId;
    }

    /**
     * @param hostId the hostId to set
     */
    public void setHostId(String hostId) {
        this.hostId = hostId;
    }
}
