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 IdentityViewModel<ContractFileTypeLocal> {
    private SimpleObjectProperty<ContractFileType> type = new SimpleObjectProperty<>();
    private SimpleStringProperty suggestFileName = new SimpleStringProperty();
    private SimpleStringProperty lang = new SimpleStringProperty();
    private SimpleStringProperty value = new SimpleStringProperty();

    @Override
    protected void updateFrom(ContractFileTypeLocal v) {
        super.updateFrom(v);
        type.set(v.getType());
        suggestFileName.set(v.getSuggestFileName());
        lang.set(v.getLang());
        value.set(v.getValue());
    }

    @Override
    public boolean copyTo(ContractFileTypeLocal v) {
        boolean ret = super.copyTo(v);
        if (!Objects.equals(type.get(), v.getType())) {
            v.setType(type.get());
            ret = true;
        }
        if (!Objects.equals(suggestFileName.get(), v.getSuggestFileName())) {
            v.setSuggestFileName(suggestFileName.get());
            ret = true;
        }
        if (!Objects.equals(lang.get(), v.getLang())) {
            v.setLang(lang.get());
            ret = true;
        }
        if (!Objects.equals(value.get(), v.getValue())) {
            v.setValue(value.get());
            ret = true;
        }
        return ret;
    }
}
