Açıklaması şöyle
A more powerful solution is Instance (resembles Spring’s ObjectProvider, and extends Provider) because it comes withan iterator, which allows running for-loops over multi-valued dependencies (0..n)a stream() methodmethods for checking the availability and uniqueness of the dependency
Açıklaması şöyle
The following table summarizes the return value of the three boolean check methods, depending on the number of provided bean instances:# OF INSTANCES ISRESOLVABLE ISUNSATISFIED ISAMBIGUOUS0 false true false1 true false false>1 false false trueInstance also allows applying additional filters (based on type and qualifier) when invoking its “select()” method, which is most useful in combination with programmatic injection
Örnek
Şöyle yaparız
@InjectInstance<Pet> petInstances;...// loop over instances:for (Pet pet : petInstances) {...}// instance stream:petInstances.stream().forEach(...);// boolean check methods:petInstances.isResolvable();petInstances.isUnsatisfied();petInstances.isAmbiguous();
Hiç yorum yok:
Yorum Gönder