/*-
 * ~~~~~~licensing~~~~~~
 * system-group-api
 * ==========
 * Copyright (C) 2020 - 2025 EmDev LLC
 * ==========
 * You may not use this file except in accordance with the License Terms of the Copyright
 * Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
 * rights to the Software and any copies are the property of the Copyright Holder. Unless
 * it is explicitly allowed the Copyright Holder, the User is prohibited from using the
 * Software for commercial purposes to provide services to third parties.
 * 
 * The Copyright Holder hereby declares that the Software is provided on an "AS IS".
 * Under no circumstances does the Copyright Holder guarantee or promise that the
 * Software provided by him will be suitable or not suitable for the specific purposes
 * of the User, that the Software will meet all commercial and personal subjective
 * expectations of the User, that the Software will work properly, without technical
 * errors, quickly and uninterruptedly.
 * 
 * Under no circumstances shall the Copyright Holder or its Affiliates is not liable
 * to the User for any direct or indirect losses of the User, his expenses or actual
 * damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
 * or damage to data, property, etc.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.esb.system.groups.registry.jpa.entity;

import com.sun.istack.NotNull;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "system_group_registry")
public class SystemGroupRegistry {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private long id;
    @NotNull
    @Column(name = "uuid")
    private String uuid;
    @NotNull
    @Column(name = "name")
    private String name;
    @Column(name = "description")
    private String description;
    @NotNull
    @Column(name = "create_date")
    private Date createDate;
    @Column(name = "edit_date")
    private Date editDate;
    @NotNull
    @Column(name = "created_by")
    private String createdBy;
    @Column(name = "edited_by")
    private String editedBy;
    @Column(name = "version")
    private double version;
    @Column(name = "type")
    private String type;
    @Column(name = "connector_id")
    private String connectorId;
    @Column(name = "description_file_url")
    private String descriptionFileUrl;
    @Column(name = "endpoint_name")
    private String endpointName;
    @Column(name = "address")
    private String address;
    @Column(name = "response_type")
    private String responseType;

    @OneToMany(mappedBy = "systemGroupRegistry", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<SystemGroupMethodRegistry> systemGroupMethodRegistries;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getUuid() {
        return uuid;
    }

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

    public String getName() {
        return name;
    }

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

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getEditDate() {
        return editDate;
    }

    public void setEditDate(Date editDate) {
        this.editDate = editDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public String getEditedBy() {
        return editedBy;
    }

    public void setEditedBy(String editedBy) {
        this.editedBy = editedBy;
    }

    public double getVersion() {
        return version;
    }

    public void setVersion(double version) {
        this.version = version;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getConnectorId() {
        return connectorId;
    }

    public void setConnectorId(String connectorId) {
        this.connectorId = connectorId;
    }

    public String getDescriptionFileUrl() {
        return descriptionFileUrl;
    }

    public void setDescriptionFileUrl(String descriptionFileUrl) {
        this.descriptionFileUrl = descriptionFileUrl;
    }

    public String getEndpointName() {
        return endpointName;
    }

    public void setEndpointName(String endpointName) {
        this.endpointName = endpointName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getResponseType() {
        return responseType;
    }

    public void setResponseType(String responseType) {
        this.responseType = responseType;
    }

    public List<SystemGroupMethodRegistry> getSystemGroupMethodRegistries() {
        return systemGroupMethodRegistries;
    }

    public void setSystemGroupMethodRegistries(List<SystemGroupMethodRegistry> systemGroupMethodRegistries) {
        this.systemGroupMethodRegistries = systemGroupMethodRegistries;
    }

    @Override
    public int hashCode() {
        return Objects.hash(address, connectorId, createDate, createdBy, description, descriptionFileUrl, editDate,
                editedBy, endpointName, uuid, id, name, responseType, systemGroupMethodRegistries, type, version);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        SystemGroupRegistry other = (SystemGroupRegistry) obj;
        return Objects.equals(address, other.address) && Objects.equals(connectorId, other.connectorId)
                && Objects.equals(createDate, other.createDate) && Objects.equals(createdBy, other.createdBy)
                && Objects.equals(description, other.description)
                && Objects.equals(descriptionFileUrl, other.descriptionFileUrl)
                && Objects.equals(editDate, other.editDate) && Objects.equals(editedBy, other.editedBy)
                && Objects.equals(endpointName, other.endpointName) && Objects.equals(uuid, other.uuid)
                && id == other.id && Objects.equals(name, other.name)
                && Objects.equals(responseType, other.responseType)
                && Objects.equals(type, other.type)
                && Double.doubleToLongBits(version) == Double.doubleToLongBits(other.version);
    }

    @Override
    public String toString() {
        return "SystemGroupRegistry [id=" + id + ", uuid=" + uuid + ", name=" + name + ", description=" + description
                + ", createDate=" + createDate + ", editDate=" + editDate + ", createdBy=" + createdBy + ", editedBy="
                + editedBy + ", version=" + version + ", type=" + type + ", connectorId=" + connectorId
                + ", descriptionFileUrl=" + descriptionFileUrl + ", endpointName=" + endpointName + ", address="
                + address + ", responseType=" + responseType + ", systemGroupMethodRegistries=" + systemGroupMethodRegistries
                + "]";
    }

}
