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.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@jakarta.persistence.Entity
@Table(name = "FUNC", schema = "supplier_ms")
public class Function implements IdentityEntity, NamedEntity, Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false)
    private Integer id;

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

    @Column(name = "FUNC_KEY")
    private String key;

    @Column(name = "IS_ACTIVE")
    private boolean active;

    @Column(name = "CONTROLLER", columnDefinition = "VARCHAR(255)")
    private String controller;

    @Column(name = "ICON", columnDefinition = "VARCHAR(255)")
    private String icon;

    @Column(name = "DESCRIPTION", columnDefinition = "VARCHAR(255)")
    private String description;

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

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