Skip to content

Commit a8b5ee1

Browse files
refactor: set actuator type in actuator entity
1 parent fe49adb commit a8b5ee1

File tree

9 files changed

+27
-14
lines changed

9 files changed

+27
-14
lines changed

src/env/artifact/environment/roomartifact/AmbientLight.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class AmbientLight extends AbstractActuatorInRoomArtifact implements Dimm
2929
*/
3030
void init(final String roomId) {
3131
super.init(ActuatorType.AMBIENT_LIGHT, new RoomID(roomId));
32-
this.actuator = new DimmableActuator(this.getActuatorID());
32+
this.actuator = new DimmableActuator(this.getActuatorID(), ActuatorType.AMBIENT_LIGHT);
3333
this.wotInvoker = new WotInvoker();
3434
}
3535

src/env/artifact/environment/roomartifact/Cooler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Cooler extends AbstractActuatorInRoomArtifact implements Switchable
2929
*/
3030
void init(final String roomId) {
3131
super.init(ActuatorType.COOLING, new RoomID(roomId));
32-
this.actuator = new SwitchableActuator(this.getActuatorID());
32+
this.actuator = new SwitchableActuator(this.getActuatorID(), ActuatorType.COOLING);
3333
this.wotInvoker = new WotInvoker();
3434
}
3535

src/env/artifact/environment/roomartifact/Heater.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Heater extends AbstractActuatorInRoomArtifact implements Switchable
2929
*/
3030
void init(final String roomId) {
3131
super.init(ActuatorType.HEATING, new RoomID(roomId));
32-
this.actuator = new SwitchableActuator(this.getActuatorID());
32+
this.actuator = new SwitchableActuator(this.getActuatorID(), ActuatorType.HEATING);
3333
this.wotInvoker = new WotInvoker();
3434
}
3535

src/env/artifact/environment/roomartifact/SurgicalLight.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class SurgicalLight extends AbstractActuatorInRoomArtifact implements Dim
2929
*/
3030
void init(final String roomId) {
3131
super.init(ActuatorType.SURGICAL_LIGHT, new RoomID(roomId));
32-
this.actuator = new DimmableActuator(this.getActuatorID());
32+
this.actuator = new DimmableActuator(this.getActuatorID(), ActuatorType.SURGICAL_LIGHT);
3333
this.wotInvoker = new WotInvoker();
3434
}
3535

src/env/artifact/environment/roomartifact/Ventilation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Ventilation extends AbstractActuatorInRoomArtifact implements Dimma
2929
*/
3030
void init(final String roomId) {
3131
super.init(ActuatorType.VENTILATION, new RoomID(roomId));
32-
this.actuator = new DimmableActuator(this.getActuatorID());
32+
this.actuator = new DimmableActuator(this.getActuatorID(), ActuatorType.VENTILATION);
3333
this.wotInvoker = new WotInvoker();
3434
}
3535

src/env/entity/actuator/Actuator.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,34 @@
1515
*/
1616
public class Actuator {
1717
private final ActuatorID actuatorID;
18+
private final ActuatorType actuatorType;
1819

1920
/**
2021
* Default constructor.
2122
* @param actuatorID the actuator id.
23+
* @param actuatorType the actuator type.
2224
*/
23-
public Actuator(final ActuatorID actuatorID) {
25+
public Actuator(final ActuatorID actuatorID, final ActuatorType actuatorType) {
2426
this.actuatorID = actuatorID;
27+
this.actuatorType = actuatorType;
2528
}
2629

2730
/**
2831
* Get the actuator id.
2932
* @return the actuator id.
3033
*/
31-
public final ActuatorID getId() {
34+
public ActuatorID getId() {
3235
return this.actuatorID;
3336
}
3437

38+
/**
39+
* Get the actuator type.
40+
* @return the actuator type.
41+
*/
42+
public ActuatorType getActuatorType() {
43+
return this.actuatorType;
44+
}
45+
3546
@Override
3647
public final boolean equals(final Object other) {
3748
if (this == other) {

src/env/entity/actuator/DimmableActuator.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ public class DimmableActuator extends Actuator {
1717
/**
1818
* Default constructor.
1919
* @param actuatorID the actuator id.
20+
* @param actuatorType the actuator type.
2021
*/
21-
public DimmableActuator(final ActuatorID actuatorID) {
22-
super(actuatorID);
22+
public DimmableActuator(final ActuatorID actuatorID, final ActuatorType actuatorType) {
23+
super(actuatorID, actuatorType);
2324
}
2425

2526
/**

src/env/entity/actuator/SwitchableActuator.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ public class SwitchableActuator extends Actuator {
1717
/**
1818
* Default constructor.
1919
* @param actuatorID the actuator id.
20+
* @param actuatorType the actuator type.
2021
*/
21-
public SwitchableActuator(final ActuatorID actuatorID) {
22-
super(actuatorID);
22+
public SwitchableActuator(final ActuatorID actuatorID, final ActuatorType actuatorType) {
23+
super(actuatorID, actuatorType);
2324
}
2425

2526
/**

src/test/java/entity/actuator/ActuatorTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
* Test for {@link Actuator} entity.
2121
*/
2222
class ActuatorTest {
23-
private final Actuator actuator = new Actuator(new ActuatorID("actuator1"));
24-
private final Actuator actuatorDifferentRef = new Actuator(new ActuatorID("actuator1"));
25-
private final Actuator differentActuator = new Actuator(new ActuatorID("actuator2"));
23+
private final Actuator actuator = new Actuator(new ActuatorID("actuator1"), ActuatorType.HEATING);
24+
private final Actuator actuatorDifferentRef = new Actuator(new ActuatorID("actuator1"), ActuatorType.COOLING);
25+
private final Actuator differentActuator = new Actuator(new ActuatorID("actuator2"), ActuatorType.HEATING);
2626

2727
@Test
2828
@DisplayName("An actuator must not be equal to other actuators with different id other classes")

0 commit comments

Comments
 (0)