Below is my requirement with a simple example:
public interface Animal {}
@Component
@Order(1)
public class Hippo implements Animal{}
@Component
@Order(2)
public class Crocodile implements Animal{}
I want to inject them into two List's with different orders. eg landAnimals should have Hippo in the first index and Crocodile in the second index while waterAnimals should have Crocodile in the first index and Hippo in the second index.
@Autowired
private List<Animal> landAnimals; // 0-Hippo & 1-Crocodile (achieved with @Order)
@Autowired
private List<Animal> waterAnimals; // 0-Crocodile & 1-Hippo (not achieved)
@Order, can we change it dynamically?