-
Sub-task
-
Resolution: Done
-
Medium
-
None
-
None
-
None
-
None
Some eithers use generics in a not optimal way in:
- CertificationChangeTransition
- LifeCycleTransition
- LifecycleBusinessLogic
Bar.java
private Either<? extends Component, SomeType> methodName(/*...*/) // should be replaced by private <T extends Component> Either<T, SomeType> methodName(/*...*/)
As explained in Effective Java, the wildcard pattern should only be used following the PECS pattern:
- Use the <? extends T> wildcard if you need to retrieve object of type T from a collection.
- Use the <? super T> wildcard if you need to put objects of type T in a collection
- If you need to satisfy both things, well, don’t use any wildcard.
In this case, fixing the type is enough as we don't know if the result will be stored or consumed. Secondly this prevents extra unsafe casting when retrieving components.