Archive

Posts Tagged ‘Lookup’

Fastest way to clear the Lookup contents

Suppose you have an AbstractLookup with a registered InstanceContent:

InstanceContent ic = new InstanceContent();
Lookup lkp = new AbstractLookup(ic);

The fastest way to clear all the Lookup contents:

ic.set(Collections.emptyList(), null);

Now I’m looking for a convenience command to remove all instances of a given type. I want to replace this code:

for (MyClass my : lkp.lookupAll(MyClass.class)) {  
   ic.remove(my);
}

Perhaps someone has an idea?

Advertisements
Categories: Java, NB Platform, NetBeans Tags: