|
8 | 8 | import com.thoughtworks.xstream.annotations.XStreamOmitField; |
9 | 9 | import edu.wpi.grip.core.events.*; |
10 | 10 | import edu.wpi.grip.core.settings.ProjectSettings; |
| 11 | +import edu.wpi.grip.core.sockets.InputSocket; |
| 12 | +import edu.wpi.grip.core.sockets.OutputSocket; |
| 13 | +import edu.wpi.grip.core.sockets.SocketHint; |
11 | 14 |
|
12 | 15 | import javax.inject.Inject; |
13 | 16 | import java.util.*; |
|
30 | 33 | */ |
31 | 34 | @Singleton |
32 | 35 | @XStreamAlias(value = "grip:Pipeline") |
33 | | -public class Pipeline { |
| 36 | +public class Pipeline implements ConnectionValidator { |
34 | 37 |
|
35 | 38 | @Inject |
36 | 39 | @XStreamOmitField |
@@ -176,28 +179,13 @@ public ProjectSettings getProjectSettings() { |
176 | 179 | * @return true if a connection can be made from the given output socket to the given input socket |
177 | 180 | */ |
178 | 181 | @SuppressWarnings("unchecked") |
179 | | - public boolean canConnect(Socket socket1, Socket socket2) { |
180 | | - final OutputSocket<?> outputSocket; |
181 | | - final InputSocket<?> inputSocket; |
182 | | - |
183 | | - // One socket must be an input and one must be an output |
184 | | - if (socket1.getDirection() == socket2.getDirection()) { |
185 | | - return false; |
186 | | - } |
187 | | - |
188 | | - if (socket1.getDirection().equals(Socket.Direction.OUTPUT)) { |
189 | | - outputSocket = (OutputSocket) socket1; |
190 | | - inputSocket = (InputSocket) socket2; |
191 | | - } else { |
192 | | - inputSocket = (InputSocket) socket1; |
193 | | - outputSocket = (OutputSocket) socket2; |
194 | | - } |
195 | | - |
196 | | - final SocketHint outputHint = socket1.getSocketHint(); |
197 | | - final SocketHint inputHint = socket2.getSocketHint(); |
| 182 | + @Override |
| 183 | + public boolean canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket) { |
| 184 | + final SocketHint outputHint = outputSocket.getSocketHint(); |
| 185 | + final SocketHint inputHint = inputSocket.getSocketHint(); |
198 | 186 |
|
199 | 187 | // The input socket must be able to hold the type of value that the output socket contains |
200 | | - if (!inputHint.getType().isAssignableFrom(outputHint.getType())) { |
| 188 | + if (!inputHint.isCompatibleWith(outputHint)) { |
201 | 189 | return false; |
202 | 190 | } |
203 | 191 |
|
|
0 commit comments