Re: LookupEvent Generics and Wildcard [rawtype] best usage pattern suggestion

Benno Markiewicz <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <CAA_aP4i_ChXZeYr4Z+_F_622n+WhmEKR+dNNEJsr0NBUfwMCpg@mail.gmail.com>
You could also use Result<Object>, so there is nothing to worry about
generics wildcard typing.

Den 29 dec. 2016 2:31 em skrev "bruehlicke" <[email protected]>:

To answer myself, there is actually a critical difference between <?> and
<? extends Object> as the first is reifiable whereas the second is not. See
http://stackoverflow.com/questions/14346622/list-vs-list-extends-object

This is critical as my code is using "instanceof" and hence need the <?>.


Code:
    @Override
    public void resultChanged(LookupEvent lookupEvent) {
        Lookup.Result<?> r = (Lookup.Result) lookupEvent.getSource();
        Collection<?> c = r.allInstances();
        if (!c.isEmpty()) {
            for (Object o : c) {
                if (o instanceof XYZ) {




This is at least my understanding. Correct me if I am wrong.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.