package com.ecep.contract.model;

import java.io.Serializable;
import java.util.Objects;

import com.ecep.contract.util.HibernateProxyUtils;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "BANK", schema = "supplier_ms")
public class Bank implements BasedEntity, IdentityEntity, Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false)
    private Integer id;

    @Column(name = "CODE")
    private String code;

    @Column(name = "NAME")
    private String name;

    @Override
    public String toPrettyString() {
        return code + " " + name;
    }

    @Override
    public final boolean equals(Object object) {
        if (this == object)
            return true;
        if (object == null || HibernateProxyUtils.isNotEffectiveClassEquals(this, object))
            return false;
        Bank bank = (Bank) object;
        return getId() != null && Objects.equals(getId(), bank.getId());
    }

    @Override
    public final int hashCode() {
        return HibernateProxyUtils.hashCode(this);
    }
}
