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

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

import java.util.Objects;

@Table("hmd_virtual_io_adapter")
public class HmdVirtualIoAdapter extends HmdGenericEntity {
    @Column("target_id")
    private Long targetId; // 目标id，取值hmd_partition的id或hmd_profile的id
    @Column("target_type")
    private String targetType; // 目标类型，取值：partition或profile
    @Column("adapter_id")
    private Long adapterId; // 适配器id，取值hmd_server_io_adapter的id
    @Column("is_required")
    private Boolean isRequired; // 1 必须 0 期望

    private HmdPartition partition; // 所属的lpar/vios
    private HmdProfile profile; // 所属的概要文件
    private HmdServerIoAdapter ioAdapter; // 关联的io适配器

    public Long getTargetId() {
        return targetId;
    }

    public void setTargetId(Long targetId) {
        this.targetId = targetId;
    }

    public String getTargetType() {
        return targetType;
    }

    public void setTargetType(String targetType) {
        this.targetType = targetType;
    }

    public Long getAdapterId() {
        return adapterId;
    }

    public void setAdapterId(Long adapterId) {
        this.adapterId = adapterId;
    }

    public Boolean getIsRequired() {
        return isRequired;
    }

    public void setIsRequired(Boolean isRequired) {
        this.isRequired = isRequired;
    }

    public HmdPartition getPartition() {
        return partition;
    }

    public HmdPartition newPartition() {
        this.partition = new HmdPartition();
        return partition;
    }

    public void setPartition(HmdPartition partition) {
        this.partition = partition;
    }

    public HmdProfile getProfile() {
        return profile;
    }

    public void setProfile(HmdProfile profile) {
        this.profile = profile;
    }

    public HmdServerIoAdapter getIoAdapter() {
        return ioAdapter;
    }

    public HmdServerIoAdapter newIoAdapter() {
        this.ioAdapter = new HmdServerIoAdapter();
        return ioAdapter;
    }

    public void setIoAdapter(HmdServerIoAdapter ioAdapter) {
        this.ioAdapter = ioAdapter;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        HmdVirtualIoAdapter that = (HmdVirtualIoAdapter) o;
        return Objects.equals(targetId, that.targetId) &&
                Objects.equals(targetType, that.targetType) &&
                Objects.equals(adapterId, that.adapterId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(targetId, targetType, adapterId);
    }
}

