package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.CompanyFileType;

import com.ecep.contract.vo.CompanyFileTypeLocalVo;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 文件类型本地化信息
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class CompanyFileTypeLocalViewModel extends IdentityViewModel<CompanyFileTypeLocalVo> {
    private SimpleObjectProperty<CompanyFileType> type = new SimpleObjectProperty<>();
    private SimpleStringProperty lang = new SimpleStringProperty();
    private SimpleStringProperty value = new SimpleStringProperty();

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

    @Override
    public boolean copyTo(CompanyFileTypeLocalVo v) {
        boolean ret = super.copyTo(v);
        if (!Objects.equals(type.get(), v.getType())) {
            v.setType(type.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;
    }
}