package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.CustomerFileType;
import com.ecep.contract.vo.CustomerFileTypeLocalVo;

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

@Data
@EqualsAndHashCode(callSuper = true)
public class CustomerFileTypeLocalViewModel extends IdentityViewModel<CustomerFileTypeLocalVo> {
    private SimpleObjectProperty<CustomerFileType> type = new SimpleObjectProperty<>();
    private SimpleStringProperty lang = new SimpleStringProperty();
    private SimpleStringProperty value = new SimpleStringProperty();

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

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