package com.bocloud.ims.entity.resource.hmc;

import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.Table;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Table("hmd_vios_volume_group")
public class HmdViosVolumeGroup extends HmdGenericEntity {
    @Column("name")
    private String name; // 名称
    @Column("vios_id")
    private Long viosId; // 所属vios的id，对应hmd_partition表的id字段
    @Column("uuid")
    private String uuid; // 唯一标识
    @Column("total_capacity")
    private Float totalCapacity; // 总容量
    @Column("available_capacity")
    private Float availableCapacity; // 可用容量
    @Column("free_capacity")
    private Float freeCapacity; // 空闲容量
    @Column("group_serial_id")
    private String groupSerialId; // 存储池序列号
    @Column("max_logical_volumes")
    private Long maxLogicalVolumes; // 最大容纳物理磁盘数
    @Column("unique_device_id")
    private String uniqueDeviceId; // 唯一设备id

    private List<HmdViosPhysicalDisk> physicalDisks; // 物理磁盘
    private List<HmdViosVirtualDisk> virtualDisks; // 虚拟磁盘
    private List<HmdViosVirtualCd> virtualCds; // 虚拟光学设备

    private HmdPartition vios; // 所属vios

    public Long getViosId() {
        return viosId;
    }

    public void setViosId(Long viosId) {
        this.viosId = viosId;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Float getTotalCapacity() {
        return totalCapacity;
    }

    public void setTotalCapacity(Float totalCapacity) {
        this.totalCapacity = totalCapacity;
    }

    public Float getAvailableCapacity() {
        return availableCapacity;
    }

    public void setAvailableCapacity(Float availableCapacity) {
        this.availableCapacity = availableCapacity;
    }

    public Float getFreeCapacity() {
        return freeCapacity;
    }

    public void setFreeCapacity(Float freeCapacity) {
        this.freeCapacity = freeCapacity;
    }

    public String getGroupSerialId() {
        return groupSerialId;
    }

    public void setGroupSerialId(String groupSerialId) {
        this.groupSerialId = groupSerialId;
    }

    public Long getMaxLogicalVolumes() {
        return maxLogicalVolumes;
    }

    public void setMaxLogicalVolumes(Long maxLogicalVolumes) {
        this.maxLogicalVolumes = maxLogicalVolumes;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUniqueDeviceId() {
        return uniqueDeviceId;
    }

    public void setUniqueDeviceId(String uniqueDeviceId) {
        this.uniqueDeviceId = uniqueDeviceId;
    }

    public List<HmdViosPhysicalDisk> getPhysicalDisks() {
        return physicalDisks;
    }

    public void setPhysicalDisks(List<HmdViosPhysicalDisk> physicalDisks) {
        this.physicalDisks = physicalDisks;
    }

    public void setPhysicalDiskUrls(List<String> urls) {
        this.physicalDisks = urls.stream().map(url -> {
            HmdViosPhysicalDisk disk = new HmdViosPhysicalDisk();
            disk.setUrl(url);
            return disk;
        }).collect(Collectors.toList());
    }


    public List<HmdViosVirtualDisk> getVirtualDisks() {
        return virtualDisks;
    }

    public void setVirtualDisks(List<HmdViosVirtualDisk> virtualDisks) {
        this.virtualDisks = virtualDisks;
    }

    public void setVirtualDiskUrls(List<String> urls) {
        this.virtualDisks = urls.stream().map(url -> {
            HmdViosVirtualDisk disk = new HmdViosVirtualDisk();
            disk.setUrl(url);
            return disk;
        }).collect(Collectors.toList());
    }

    public List<HmdViosVirtualCd> getVirtualCds() {
        return virtualCds;
    }

    public void setVirtualCds(List<HmdViosVirtualCd> virtualCds) {
        this.virtualCds = virtualCds;
    }

    public void setVirtualCdUrls(List<String> urls) {
        this.virtualCds = urls.stream().map(url -> {
            HmdViosVirtualCd cd = new HmdViosVirtualCd();
            cd.setUrl(url);
            return cd;
        }).collect(Collectors.toList());
    }

    public HmdPartition getVios() {
        return vios;
    }

    public void setVios(HmdPartition vios) {
        this.vios = vios;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        HmdViosVolumeGroup that = (HmdViosVolumeGroup) o;
        return Objects.equals(uuid, that.uuid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), uuid);
    }
}

