wid, added implements keyword for Boolean/RangeTriggerable in all the devices

This commit is contained in:
omenem 2020-04-22 16:48:49 +02:00
parent db21aa0a26
commit 5c2f828834
4 changed files with 24 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Dimmable extends Switchable {
public class Dimmable extends Switchable implements RangeTriggerable {
public static final Connector<KnobDimmer, Dimmable> KNOB_DIMMER_DIMMABLE_CONNECTOR =
Connector.basic(KnobDimmer::getOutputs, Dimmable::getDimmers);
@ -85,4 +85,9 @@ public class Dimmable extends Switchable {
newState.setIntensity(getIntensity());
return newState;
}
@Override
public double readTriggerState() {
return intensity;
}
}

View File

@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull;
/** Represents a standard non-dimmable light */
@Entity
public class RegularLight extends Switchable {
public class RegularLight extends Switchable implements BooleanTriggerable {
/** Whether the light is on or not */
@Column(name = "light_on", nullable = false)
@ -27,4 +27,9 @@ public class RegularLight extends Switchable {
public void setOn(boolean on) {
this.on = on;
}
@Override
public boolean readTriggerState() {
return on;
}
}

View File

@ -5,7 +5,7 @@ import javax.persistence.Entity;
import javax.validation.constraints.NotNull;
@Entity
public class SecurityCamera extends Switchable {
public class SecurityCamera extends Switchable implements BooleanTriggerable {
public SecurityCamera() {
super("securityCamera");
@ -33,4 +33,9 @@ public class SecurityCamera extends Switchable {
public void setOn(boolean on) {
this.on = on;
}
@Override
public boolean readTriggerState() {
return on;
}
}

View File

@ -1,6 +1,5 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import com.google.common.base.Objects;
import java.math.BigDecimal;
import javax.persistence.Column;
@ -9,7 +8,7 @@ import javax.validation.constraints.NotNull;
/** A smart plug that can be turned either on or off */
@Entity
public class SmartPlug extends Switchable {
public class SmartPlug extends Switchable implements BooleanTriggerable {
/** The average consumption of an active plug when on in Watt */
public static final Double AVERAGE_CONSUMPTION_KW = 200.0;
@ -46,4 +45,9 @@ public class SmartPlug extends Switchable {
public SmartPlug() {
super("smartPlug");
}
@Override
public boolean readTriggerState() {
return on;
}
}