package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.ProjectFileType;
import com.ecep.contract.vo.ProjectFileTypeLocalVo;

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

@Data
@EqualsAndHashCode(callSuper = true)
public class ProjectFileTypeLocalViewModel extends IdentityViewModel<ProjectFileTypeLocalVo> {
    private SimpleObjectProperty<ProjectFileType> type = new SimpleObjectProperty<>();
    private SimpleStringProperty lang = new SimpleStringProperty();
    private SimpleStringProperty value = new SimpleStringProperty();

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

    @Override
    public boolean copyTo(ProjectFileTypeLocalVo 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;
    }
}