package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.model.InventoryCatalog;

import javafx.beans.property.SimpleStringProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class InventoryCatalogViewModel extends IdentityViewModel<InventoryCatalog> {
    private SimpleStringProperty name = new SimpleStringProperty();
    private SimpleStringProperty code = new SimpleStringProperty();

    @Override
    protected void updateFrom(InventoryCatalog v) {
        super.updateFrom(v);
        name.set(v.getName());
        code.set(v.getCode());
    }

    @Override
    public boolean copyTo(InventoryCatalog v) {
        boolean ret = super.copyTo(v);
        if (!Objects.equals(name.get(), v.getName())) {
            v.setName(name.get());
            ret = true;
        }
        if (!Objects.equals(code.get(), v.getCode())) {
            v.setCode(code.get());
            ret = true;
        }
        return ret;
    }

}
