Thursday Dec 31, 2009

Simplification of Node Creation

I received a bunch of comments from Jesse Glick about How to Create a Web Service Client with Groovy and NetBeans Platform 6.8. I'll be changing that article a lot, as a result.

Here's one of them:

     @Override
     public void resultChanged(LookupEvent le) {
-        quotes = new ArrayList<ShakesWsClient>();
-        Collection<? extends ShakesWsClient> coll = result.allInstances();
-        for (ShakesWsClient client : coll) {
-            //Add all the ShakesWsClient in the context to the ArrayList:
-            quotes.add(client);
-            //Call "createKeys":
-            refresh(true);
-        }
-
+        quotes = new ArrayList<ShakesWsClient>(result.allInstances());
+        //Call "createKeys":
+        refresh(true);
     }

I.e., no need to iterate through the result instances, just pass them in as the ArrayList parameter.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« December 2009 »
SunMonTueWedThuFriSat
  
2
4
5
6
7
9
12
13
16
17
18
19
23
24
25
26
27
28
  
       
Today