package de.ctdo.bunti.devices;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import de.ctdo.bunti.DeviceChangedEvent;
import de.ctdo.bunti.model.BuntiSwitchingDevice;


@Component
public class DeviceMixerImpl implements DeviceMixer, ApplicationListener<DeviceChangedEvent>  {
	
	@Override
	public final void onApplicationEvent(DeviceChangedEvent arg0) {
		
		if( arg0.getDevice() instanceof BuntiSwitchingDevice) {
			
			BuntiSwitchingDevice switchDev = (BuntiSwitchingDevice)arg0.getDevice();	
			switchDev.setValuesFromOptions(arg0.getOptions());
			
		}
		
	}

}
