package net.ranides.assira.asm;

import net.ranides.assira.events.EventRouter;
import net.ranides.assira.observable.BeanEvent;

import java.util.List;

public class SimpleObservableModel extends SimpleModel {

    private final EventRouter router;

    public SimpleObservableModel(EventRouter router) {
        this.router = router;
    }

    @Override
    public void setName(String name) {
        router.signalEvent(BeanEvent.change(this, "name", getName(), name));
        super.setName(name);
    }

    @Override
    public void setAge(Integer age) {
        router.signalEvent(BeanEvent.change(this, "age", getAge(), age));
        super.setAge(age);
    }

    @Override
    public void setCost(List<Double> cost) {
        router.signalEvent(BeanEvent.change(this, "cost", getCost(), cost));
        super.setCost(cost);
    }

}
