Interface ImplementationPicker


  • @ConsumerType
    public interface ImplementationPicker
    Defines a strategy to choose an implementation for a model if multiple are registered for the same interface or super class.

    With using the @Model.adapters attribute it is possible to define interfaces or super classes to which the model implementation is an adaption target. It is possible that multiple models implement the same type.

    In this case services implementing the ImplementationPicker interface are queried to decide which implementation should be chosen. If multiple implementations of this interface exists they are queried one after another by service ranking. The first that picks an implementation is the winner.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @Nullable java.lang.Class<?> pick​(@NotNull java.lang.Class<?> adapterType, @NotNull java.lang.Class<?>[] implementationsTypes, @NotNull java.lang.Object adaptable)
      Select an implementation for the adapter class to which the adaptable should be adapted to.
    • Method Detail

      • pick

        @Nullable
        @Nullable java.lang.Class<?> pick​(@NotNull
                                          @NotNull java.lang.Class<?> adapterType,
                                          @NotNull
                                          @NotNull java.lang.Class<?>[] implementationsTypes,
                                          @NotNull
                                          @NotNull java.lang.Object adaptable)
        Select an implementation for the adapter class to which the adaptable should be adapted to.
        Parameters:
        adapterType - Adapter type. Never null.
        implementationsTypes - Available implementations. It is guaranteed that they can be assigned to the adapter type. Never null and has always at least one entry.
        adaptable - For reference: the adaptable. May be enquired to detect the context of the adaption. Never null.
        Returns:
        If an implementation is chosen the class is returned, otherwise null.