samples/extensibleicon/src/org/apidesign/extensibleicon/CatQuery.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:53:51 +0200
changeset 89 06f2e2a3d986
child 132 3bc4c54f4bcc
permissions -rw-r--r--
review2: ExtIcon example used to demonstrate the beauty of query pattern. two sections merged into one, a bit of reordering. Please review.
     1 package org.apidesign.extensibleicon;
     2 
     3 import org.openide.util.Lookup;
     4 
     5 // BEGIN: ext.CatQuery
     6 public class CatQuery {
     7     private CatQuery() { }
     8     
     9     public static boolean isCat(ExtIcon icon) {
    10         for (CatQueryImplementation impl : Lookup.getDefault().lookupAll(CatQueryImplementation.class)) {
    11             Boolean res = impl.isCat(icon);
    12             if (res != null) {
    13                 return res;
    14             }
    15         }
    16 
    17         for (CatQueryImplementation impl : icon.getLookup().lookupAll(CatQueryImplementation.class)) {
    18             Boolean res = impl.isCat(icon);
    19             if (res != null) {
    20                 return res;
    21             }
    22         }
    23         
    24         return false;
    25     }
    26 }
    27 // END: ext.CatQuery