Developer documentation

Advanced slot configurations

In the previous example, we used the @JIPipeInputSlot and @JIPipeOutputSlot annotations with autoCreate = true to automatically configure the slots.

This is not sufficient for more complicated algorithms that require

  • Restricting the number of slots
  • Restricting the allowed data types
  • Users to add more slots or remove existing ones

A custom JIPipeSlotConfiguration can be used to implement such more advanced behaviors .For many cases, the default implementation JIPipeDefaultMutableSlotConfiguration and its builder are sufficient.

The slot configuration can be set during instantiation of the algorithm:

public MyAlgorithm(JIPipeNodeInfo info) {
    super(info, JIPipeMutableSlotConfiguration.builder()
    .addInputSlot("Input", ImagePlusData.class)

When creating custom slot configurations, please keep the following tips in your mind:

  • The slots of JIPipeMutableSlotConfiguration are by default unsealed – meaning that users can add more slots. Use the seal() functions to prevent this.
  • Do not create static slot configurations. Each algorithm should have its own instance. Use a private static function if you want to work outside the capabilities of the builder.
  • You should keep the @AlgorithmInputSlot and @AlgorithmOutputSlot annotations. They are required for the algorithm finder and generating tooltips.