To quote Joshua Bloch in Effective Java third Edition:
tip
Using wildcard types in your APIs, while tricky, makes the APIs far more flexible. If you write a library that will be widely used, the proper use of wildcard types should be considered mandatory. Remember the basic rule: producer-extends, consumer-super (PECS). Also remember that all Comparables and Comparators are consumers.
Use the inspection options to toggle the reporting for:
invariant classes. An example of an invariant class is java.util.List<T> because it both accepts values (via the List.add(T) method) and produces values (via the T List.get() method).
On the other hand, contravariant classes only receive values, for example, java.util.function.Consumer<T> with the only method accept(T). Similarly, covariant classes only produce values, for example, java.util.function.Supplier<T> with the only method T get().
People often use bounded wildcards in covariant/contravariant classes but avoid wildcards in invariant classes, for example, void process(List<? extends T> l). Disable this option to ignore such invariant classes and leave them rigidly typed, for example, .
voidprocess(List<T> l)
private methods, which can be considered as not a part of the public API
instance methods
Inspection options
Here you can find the description of settings available for the Can use bounded wildcard inspection, and the reference of their default values.
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.