Pipeline implements ConnectionValidator, SettingsProvider, StepIndexer { @SuppressWarnings("unchecked") @Override public boolean canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket) { final SocketHint outputHint = outputSocket.getSocketHint(); final SocketHint inputHint = inputSocket.getSocketHint(); if (!inputHint.isCompatibleWith(outputHint)) { return false; } if (!inputSocket.getConnections().isEmpty()) { return false; } final boolean[] backwards = {false}; outputSocket.getStep().ifPresent(outputStep -> inputSocket.getStep().ifPresent(inputStep -> { if (!isBefore(outputStep, inputStep)) { backwards[0] = true; } })); return !backwards[0]; }  void clear(); final ImmutableList<Source> getSources(); final ImmutableList<Step> getSteps(); Set<Connection> getConnections(); @Override ProjectSettings getProjectSettings(); @Override AppSettings getAppSettings(); @Override CodeGenerationSettings getCodeGenerationSettings(); @SuppressWarnings("unchecked") @Override boolean canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket); @Subscribe void onSourceAdded(SourceAddedEvent event); @Subscribe void onSourceRemoved(SourceRemovedEvent event); void addStepBetween(Step stepToAdd, @Nullable Step lower, @Nullable Step higher); void moveStepBetween(Step toMove, @Nullable Step lower, @Nullable Step higher); void addStep(int index, Step step); void addStep(Step step); void removeStep(Step step); synchronized void moveStep(Step step, int delta); @Override int indexOf(Step step); @Subscribe void onConnectionAdded(ConnectionAddedEvent event); @Subscribe void onConnectionRemoved(ConnectionRemovedEvent event); @Subscribe void onProjectSettingsChanged(ProjectSettingsChangedEvent event); @Subscribe void onAppSettingsChanged(AppSettingsChangedEvent event); @Subscribe void onCodeGenerationSettingsChanged(CodeGenerationSettingsChangedEvent event);  }
@Test @SuppressWarnings("unchecked") public void testCannotConnectIncompatibleTypes() { InputSocket<Number> a = isf.create(SocketHints.createNumberSocketHint("a", 0.0)); OutputSocket<String> b = osf.create(new SocketHint.Builder<>(String.class).identifier("b") .initialValue("").build()); assertFalse("Should not be able to connect incompatible types", pipeline.canConnect( (OutputSocket) b, (InputSocket) a)); }