package dev.fyloz.trial.colorrecipesexplorer.model.dto;

import dev.fyloz.trial.colorrecipesexplorer.model.MaterialType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MaterialTypeEditorDto {

    private Long id;

    private String oldName;

    private String name;

    private String oldPrefix;

    private String prefix;

    private boolean usePercentages;

    public MaterialTypeEditorDto(MaterialType materialType) {
        this.id = materialType.getId();
        this.oldName = materialType.getName();
        this.name = materialType.getName();
        this.oldPrefix = materialType.getPrefix();
        this.prefix = materialType.getPrefix();
        this.usePercentages = materialType.getUsePercentages();
    }

    public MaterialType getMaterialType() {
        return new MaterialType(id, name, prefix, usePercentages, false);
    }

    public MaterialType getOldMaterialType() {
        return new MaterialType(id, oldName, oldPrefix, usePercentages, false);
    }

}
