Begin gemaakt met devices die events kunnen sturen naar applications via main opdat actions worden uitgevoerd.
This commit is contained in:
@@ -1,31 +1,18 @@
|
||||
package pm.device;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Queue;
|
||||
|
||||
import pm.device.feature.Feature;
|
||||
import pm.event.Event;
|
||||
|
||||
|
||||
public abstract class Device {
|
||||
protected ArrayList<Feature> featureList;
|
||||
protected Queue<Event> eventQueue;
|
||||
|
||||
protected Device() {
|
||||
featureList = new ArrayList<Feature>();
|
||||
protected Device(Queue<Event> eventQueue) {
|
||||
this.eventQueue = eventQueue;
|
||||
initialise();
|
||||
}
|
||||
|
||||
public void addFeature(Feature feature) {
|
||||
if (!hasFeature(feature)) {
|
||||
if (this instanceof feature.getClass()) {
|
||||
|
||||
}
|
||||
featureList.add(feature);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFeature(Feature feature) {
|
||||
featureList.remove(feature);
|
||||
}
|
||||
|
||||
public boolean hasFeature(Feature feature) {
|
||||
return featureList.contains(feature);
|
||||
}
|
||||
public void initialise() {}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package pm.device;
|
||||
|
||||
import pm.device.feature.Feature;
|
||||
import pm.device.feature.Restart;
|
||||
|
||||
public enum Features {
|
||||
Restart ((Class<Restart>)Restart.class);
|
||||
|
||||
Features(Class<Feature> feature) {
|
||||
}
|
||||
}
|
||||
18
java/src/pm/device/example/Example.java
Normal file
18
java/src/pm/device/example/Example.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package pm.device.example;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import pm.action.Action;
|
||||
import pm.device.Device;
|
||||
import pm.event.Event;
|
||||
|
||||
public class Example extends Device {
|
||||
public Example(Queue<Event> eventQueue) {
|
||||
super(eventQueue);
|
||||
}
|
||||
|
||||
public void initialise() {
|
||||
Event event = new Event(Action.START);
|
||||
eventQueue.add(event);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package pm.device.exampledevice;
|
||||
|
||||
import pm.device.Device;
|
||||
import pm.device.Features;
|
||||
|
||||
public class ExampleDevice extends Device {
|
||||
public ExampleDevice() {
|
||||
addFeature(Features.Restart);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
public void restart() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pm.device.feature;
|
||||
|
||||
public interface Feature {
|
||||
public void apply();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package pm.device.feature;
|
||||
|
||||
public interface Restart extends Feature {
|
||||
public static final String feature = "RESTART";
|
||||
|
||||
public void stop();
|
||||
public void restart();
|
||||
}
|
||||
Reference in New Issue
Block a user