Package org.apache.sling.models.spi

# 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

Modifier and Type
Method
Description
`@Nullable Class<?>`
`pick(@NotNull Class<?> adapterType, @NotNull Class<?>[] implementationsTypes, @NotNull Object adaptable)`
Select an implementation for the adapter class to which the adaptable should be adapted to.

## Method Details

### pick

@Nullable @Nullable Class<?> pick(@NotNull @NotNull Class<?> adapterType, @NotNull @NotNull Class<?>[] implementationsTypes, @NotNull @NotNull 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.