package ctbrec.ui.tabs.recorded;

import java.util.Optional;

import ctbrec.Model;
import ctbrec.ModelGroup;
import ctbrec.recorder.Recorder;

public class ModelName {
    private Model mdl;
    private Recorder rec;

    public ModelName(Model model, Recorder recorder) {
        mdl = model;
        rec = recorder;
    }

    @Override
    public String toString() {
        Optional<ModelGroup> modelGroup = rec.getModelGroup(mdl);
        String s;
        if (modelGroup.isPresent()) {
            s = modelGroup.get().getName() + " (aka " + mdl.getDisplayName() + ')';
        } else {
            return mdl.toString();
        }
        return s;
    }
}