removed Devices classes
This commit is contained in:
parent
4f288256e8
commit
ed69f6a0e3
|
@ -1,9 +0,0 @@
|
|||
package de.ctdo.bunti.devices;
|
||||
|
||||
|
||||
|
||||
public interface DeviceMixer {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue