package be.iminds.ilabt.jfed.rspec.model;

import java.util.Objects;

/**
 * DiskImage
 */
public class DiskImage {
    private final String name; //required by xsd
    private final String url;
    private final String os;
    private final String version;
    private final String description;
    private final Boolean defaultBool;

    public DiskImage(String name, String url, String os, String version, String description, Boolean defaultBool) {
        //assert name != null; //do not do this, see https://ibcn-jira.intec.ugent.be/browse/FEDIBBTDEV-774
//        assert name != null || url != null;
        this.name = name;
        this.url = url;
        this.os = os;
        this.version = version;
        this.description = description;
        this.defaultBool = defaultBool;
    }

    public DiskImage(String name) {
        //assert(name != null); //do not do this, see https://ibcn-jira.intec.ugent.be/browse/FEDIBBTDEV-774
        this.name = name;
        this.url = null;
        this.os = null;
        this.version = null;
        this.description = null;
        this.defaultBool = null;
    }

    public String getName() {
        return name;
    }

    public String getUrl() {
        return url;
    }

    public String getOs() {
        return os;
    }

    public String getVersion() {
        return version;
    }

    public String getDescription() {
        return description;
    }

    public Boolean isDefault() {
        return defaultBool;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        DiskImage diskImage = (DiskImage) o;

        if (description != null ? !Objects.equals(description, diskImage.description) : diskImage.description != null)
            return false;
        if (name != null ? !Objects.equals(name, diskImage.name) : diskImage.name != null) return false;
        if (os != null ? !Objects.equals(os, diskImage.os) : diskImage.os != null) return false;
        if (url != null ? !Objects.equals(url, diskImage.url) : diskImage.url != null) return false;
        if (version != null ? !Objects.equals(version, diskImage.version) : diskImage.version != null) return false;
        if (defaultBool != null ? !Objects.equals(defaultBool, diskImage.defaultBool) : diskImage.defaultBool != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (url != null ? url.hashCode() : 0);
        result = 31 * result + (os != null ? os.hashCode() : 0);
        result = 31 * result + (version != null ? version.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (defaultBool != null ? defaultBool.hashCode() : 0);
        return result;
    }
}
