bunti/src/main/java/de/ctdo/bunti/model/BuntiSwitchingDevice.java

42 lines
917 B
Java
Raw Normal View History

package de.ctdo.bunti.model;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.Map;
@Entity
2012-03-06 23:42:30 +00:00
public abstract class BuntiSwitchingDevice extends BuntiDevice {
2012-03-20 23:23:49 +00:00
private static final String OPTION_STATE = "state";
private boolean state = false;
2012-03-04 09:50:50 +00:00
2012-03-25 14:23:45 +00:00
public BuntiSwitchingDevice() {
2012-03-06 23:42:30 +00:00
2012-03-25 14:23:45 +00:00
}
2012-03-20 23:23:49 +00:00
2012-03-04 09:50:50 +00:00
@Override
2012-03-06 23:42:30 +00:00
public final boolean setValuesFromOptions(Map<String, Object> options) {
2012-03-20 23:23:49 +00:00
if(options.containsKey(OPTION_STATE)) {
try {
boolean value = Boolean.parseBoolean(options.get(OPTION_STATE).toString());
setState(value);
return true;
} catch (Exception e) {
return false;
}
}
2012-03-06 23:42:30 +00:00
return false;
}
@Transient
2012-03-20 23:23:49 +00:00
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
}