View Javadoc

1   /*
2    * $Id: AbstractComponentEngine.java,v 1.18 2011/06/16 09:29:40 jbmeslin Exp $
3    */
4   package org.rcfaces.core.internal.component;
5   
6   import java.util.Collection;
7   import java.util.Collections;
8   import java.util.Iterator;
9   import java.util.Map;
10  
11  import org.rcfaces.core.internal.capability.IComponentEngine;
12  
13  /**
14   * 
15   * @author Olivier Oeuillot (latest modification by $Author: jbmeslin $)
16   * @version $Revision: 1.18 $ $Date: 2011/06/16 09:29:40 $
17   */
18  public abstract class AbstractComponentEngine implements IComponentEngine {
19      private static final String REVISION = "$Revision: 1.18 $";
20  
21      static final Iterator EMPTY_ITERATOR = Collections.EMPTY_SET.iterator();
22  
23      protected final IFactory factory;
24  
25      AbstractComponentEngine(IFactory factory) {
26          if (factory == null) {
27              throw new NullPointerException("Factory is NULL !");
28          }
29          this.factory = factory;
30      }
31  
32      /*
33       * (non-Javadoc)
34       * 
35       * @see javax.faces.component.UIComponent#getFamily()
36       */
37  
38      protected static final boolean isListEmpty(Collection list) {
39          return (list == null) || (list.size() < 1);
40      }
41  
42      protected static final boolean isMapEmpty(Map map) {
43          return (map == null) || (map.size() < 1);
44      }
45  
46      protected static final Iterator iteratorList(Collection list) {
47          if (isListEmpty(list)) {
48              return EMPTY_ITERATOR;
49          }
50  
51          return list.iterator();
52      }
53  }