package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.ContractFileType;
import com.ecep.contract.model.VendorGroup;
import com.ecep.contract.model.VendorGroupRequireFileType;

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

/**
 *
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class VendorGroupRequireFileTypeViewModel extends IdentityViewModel<VendorGroupRequireFileType> {

    private SimpleObjectProperty<VendorGroup> group = new SimpleObjectProperty<>();
    private SimpleObjectProperty<ContractFileType> fileType = new SimpleObjectProperty<>();

    @Override
    protected void updateFrom(VendorGroupRequireFileType v) {
        super.updateFrom(v);
        getGroup().set(v.getGroup());
        getFileType().set(v.getFileType());
    }

    @Override
    public boolean copyTo(VendorGroupRequireFileType v) {
        boolean modified = super.copyTo(v);
        if (!Objects.equals(getGroup().get(), v.getGroup())) {
            v.setGroup(getGroup().get());
            modified = true;
        }
        if (!Objects.equals(getFileType().get(), v.getFileType())) {
            v.setFileType(getFileType().get());
            modified = true;
        }
        return modified;
    }
}
