示例#1
0
 /**
  * Get all of the view managers of the given class
  *
  * @param c ViewManager class
  * @return List of ViewManagers
  */
 public List getViewManagers(Class c) {
   List result = new ArrayList();
   List vms = getViewManagers();
   for (int i = 0; i < vms.size(); i++) {
     ViewManager vm = (ViewManager) vms.get(i);
     if (c.isAssignableFrom(vm.getClass())) {
       result.add(vm);
     }
   }
   return result;
 }
示例#2
0
 /**
  * Accepts only cookies that can provide <code>Toolbar</code>.
  *
  * @param cookie an <code>InstanceCookie</code> to test
  * @return true if the cookie can provide accepted instances
  */
 protected InstanceCookie acceptCookie(InstanceCookie cookie)
     throws java.io.IOException, ClassNotFoundException {
   Class c = cookie.instanceClass();
   if (Toolbar.class.isAssignableFrom(c)) {
     return cookie;
   }
   if (Presenter.Toolbar.class.isAssignableFrom(c)) {
     return cookie;
   }
   if (separatorClass.isAssignableFrom(c)) {
     return cookie;
   }
   return null;
 }
示例#3
0
 /** Check if the given collection is a uniform collection of the given type. */
 public static boolean isUniformCollection(Collection<?> c, Class<?> e) {
   if (e == null) {
     throw new IllegalArgumentException("Null reference type");
   }
   if (c == null) {
     throw new IllegalArgumentException("Null collection");
   }
   if (c.isEmpty()) {
     return false;
   }
   for (Object o : c) {
     if (o == null || !e.isAssignableFrom(o.getClass())) {
       return false;
     }
   }
   return true;
 }