Deleted legacy MachineContext
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 26 Sep 2019 16:17:26 +0000 (18:17 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 26 Sep 2019 16:17:26 +0000 (18:17 +0200)
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MachineContext.java [deleted file]

diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MachineContext.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MachineContext.java
deleted file mode 100644 (file)
index c22c1c7..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-package net.mograsim.plugin;
-
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-
-import net.mograsim.machine.Machine;
-import net.mograsim.machine.MachineRegistry;
-import net.mograsim.plugin.nature.ProjectMachineContext;
-
-/**
- * @deprecated use the {@link ProjectMachineContext} instead to make the context project dependent.
- */
-@Deprecated(forRemoval = true)
-public class MachineContext
-{
-       private Machine machine;
-       private Set<ContextObserver> observers;
-       private static MachineContext instance;
-
-       private MachineContext()
-       {
-               observers = new HashSet<>();
-       }
-
-       public static MachineContext getInstance()
-       {
-               if (instance == null)
-               {
-                       instance = new MachineContext();
-                       // TODO don't hardcode the Am2900
-                       instance.setMachine(MachineRegistry.getMachine("Am2900").createNew());
-               }
-               return instance;
-       }
-
-       public Machine getMachine()
-       {
-               return machine;
-       }
-
-       public void setMachine(Machine machine)
-       {
-               this.machine = machine;
-               notifyObservers(machine);
-       }
-
-       public void registerObserver(ContextObserver ob)
-       {
-               observers.add(ob);
-               ob.setMachine(Optional.ofNullable(machine));
-       }
-
-       public void deregisterObserver(ContextObserver ob)
-       {
-               observers.remove(ob);
-       }
-
-       private void notifyObservers(Machine machine)
-       {
-               observers.forEach(ob -> ob.setMachine(Optional.ofNullable(machine)));
-       }
-
-       @FunctionalInterface
-       public static interface ContextObserver
-       {
-               void setMachine(Optional<Machine> machine);
-       }
-}