package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.ContractFileType;
import com.ecep.contract.model.ContractFileTypeLocal;

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

@Data
@EqualsAndHashCode(callSuper = false)
public class ContractFileTypeLocalViewModel extends EnumViewModel<ContractFileType, ContractFileTypeLocal> {
    private SimpleStringProperty suggestFileName = new SimpleStringProperty();

    @Override
    protected void updateFrom(ContractFileTypeLocal v) {
        super.updateFrom(v);
        suggestFileName.set(v.getSuggestFileName());
    }

    @Override
    public boolean copyTo(ContractFileTypeLocal v) {
        boolean ret = super.copyTo(v);
        if (!Objects.equals(suggestFileName.get(), v.getSuggestFileName())) {
            v.setSuggestFileName(suggestFileName.get());
            ret = true;
        }
        return ret;
    }
}
