removed Devices classes

This commit is contained in:
Lucas Pleß 2012-03-26 23:02:58 +02:00
parent 4f288256e8
commit ed69f6a0e3
3 changed files with 0 additions and 75 deletions

View File

@ -1,9 +0,0 @@
package de.ctdo.bunti.devices;
public interface DeviceMixer {
}

View File

@ -1,25 +0,0 @@
package de.ctdo.bunti.devices;
import de.ctdo.bunti.control.DeviceChangedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
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());
}
}
}

View File

@ -1,41 +0,0 @@
package de.ctdo.bunti.model;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.Map;
@Entity
public abstract class BuntiSwitchingDevice extends BuntiDevice {
private static final String OPTION_STATE = "state";
private boolean state = false;
public BuntiSwitchingDevice() {
}
@Override
public final boolean setValuesFromOptions(Map<String, Object> options) {
if(options.containsKey(OPTION_STATE)) {
try {
boolean value = Boolean.parseBoolean(options.get(OPTION_STATE).toString());
setState(value);
return true;
} catch (Exception e) {
return false;
}
}
return false;
}
@Transient
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
}