Checks that SavedModelHandler only uses supported collections.
960650
def check_collections_are_supported(saved_model_handler, supported):
  """"""
  for meta_graph in saved_model_handler.meta_graphs:
    used_collection_keys = set(meta_graph.collection_def.keys())
    unsupported = used_collection_keys - supported
    if unsupported:
      raise ValueError("Unsupported collections in graph: %s\n"
                       "Use hub.create_module_spec(..., drop_collections=[...])"
                       " as appropriate." % list(unsupported))
881082
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts") // agreed, fixme
    private void clean(Collector collector) {
        Set<ObjectId> uniqueIDs = new HashSet<>();
        /*
          Logic: For each component, retrieve the collector item list of the type SCM.
          Store their IDs in a unique set ONLY if their collector IDs match with GitHub collectors ID.
         */
        for (com.capitalone.dashboard.model.Component comp : dbComponentRepository.findAll()) {
            if (!MapUtils.isEmpty(comp.getCollectorItems())) {
                List<CollectorItem> itemList = comp.getCollectorItems().get(CollectorType.SCM);
                if (itemList != null) {
                    itemList.stream().filter(ci -> ci != null && Objects.equals(ci.getCollectorId(), collector.getId())).map(BaseModel::getId).forEach(uniqueIDs::add);
                }
            }
        }
        /*
          Logic: Get all the collector items from the collector_item collection for this collector.
          If their id is in the unique set (above), keep them enabled; else, disable them.
         */
        List<GitHubRepo> repoList = new ArrayList<>();
        Set<ObjectId> gitID = new HashSet<>();
        gitID.add(collector.getId());
        gitHubRepoRepository.findByCollectorIdIn(gitID).stream().filter(Objects::nonNull).forEach(repo -> {
            if (repo.isPushed()) {return;}
            repo.setEnabled(uniqueIDs.contains(repo.getId()));
            repoList.add(repo);
        });
        gitHubRepoRepository.save(repoList);
    }
195673
def is_compatible(self, collection):
        '''

        '''
        return all([
            isinstance(collection, Collection),
            collection.head == self.head,
            collection.tail == self.tail,
            collection.padding == self.padding
        ])
692750
public static <X> void checkCollection(Collection<X> elements, Class<X> viewedAs) {
		if (elements == null || viewedAs == null) {
			throw new NullPointerException();
		}
		
		if (!Serializable.class.isAssignableFrom(viewedAs)) {
			throw new InvalidProgramException("The elements are not serializable (java.io.Serializable).");
		}
		
		for (X elem : elements) {
			if (elem == null) {
				throw new IllegalArgumentException("The collection must not contain null elements.");
			}
			
			if (!viewedAs.isAssignableFrom(elem.getClass())) {
				throw new IllegalArgumentException("The elements in the collection are not all subclasses of " + 
							viewedAs.getCanonicalName());
			}
		}
	}
980486
boolean handleFilters(Map<String, Object> filters) {
		Validate.notNull(filters, "Filters required");
		boolean changed = false;

		// clear non active filters and remove them from lastFilters
		for (Object filterKey : CollectionUtils.subtract(lastFilters.keySet(),
				filters.keySet())) {
			BeanProperty.clearBeanProperty(adaptee, (String) filterKey);
			lastFilters.remove(filterKey);
			changed = true;
		}

		// set changed active filters
		for (Entry<String, Object> entry : filters.entrySet()) {
			if (!lastFilters.containsKey(entry.getKey())
					|| !entry.getValue()
							.equals(lastFilters.get(entry.getKey()))) {
				BeanProperty.setBeanProperty(adaptee, entry.getKey(),
						entry.getValue());
				lastFilters.put(entry.getKey(), entry.getValue());
				changed = true;
			}
		}

		return changed;
	}
260166
public boolean execInsert(D6Model[] modelObjects) {
    final D6Inex includeExcludeColumnNames = null;
    return execInsert(modelObjects, includeExcludeColumnNames, false);
  }
1004901
function modelOrCollectionEventHandler(type, identifier, context, eventFormat, callback) {
        var keys = identifier;
        if (_.isString(keys)) {
            keys = ensureArray(context.props[keys]);
        }

        var isArray = _.isArray(keys);
        _.each(keys, function(value, key) {
            if (isArray) {
                key = value;
                value = undefined;
            }
            var eventName;
            if (_.isString(eventFormat)) {
                eventName = eventFormat.replace('{key}', key);
            } else {
                eventName = eventFormat(key);
            }
            context[type + CAP_ON](eventName, _.bind(callback, { key: key, value: value }), this);
        }, this);
        // we would have missed this with _.each
        if (!keys && _.isFunction(eventFormat)) {
            var eventName = eventFormat(undefined);
            if (eventName) {
                context[type + CAP_ON](eventName, _.bind(callback, {}), this);
            }
        }
        return keys;
    }
1331758
private static boolean isSupportedClass(Class<?> clazz) {
        return Observable.class.isAssignableFrom(clazz) ||
               Maybe.class.isAssignableFrom(clazz) ||
               Single.class.isAssignableFrom(clazz) ||
               Completable.class.isAssignableFrom(clazz);
    }
266061
private void checkCollectionForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
    {
        if (CHECKLEVEL_NONE.equals(checkLevel))
        {
            return;
        }

        ClassDescriptorDef      classDef;
        CollectionDescriptorDef collDef;

        for (Iterator it = modelDef.getClasses(); it.hasNext();)
        {
            classDef = (ClassDescriptorDef)it.next();
            for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
            {
                collDef = (CollectionDescriptorDef)collIt.next();
                if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
                {
                    if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
                    {
                        checkIndirectionTable(modelDef, collDef);
                    }
                    else
                    {    
                        checkCollectionForeignkeys(modelDef, collDef);
                    }
                }
            }
        }
    }
524141
def _check_model_types(self, models):
        
        if not hasattr(models, "__iter__"):
            models = {models}
        if not all([isinstance(model, (AbstractStateModel, StateElementModel)) for model in models]):
            raise TypeError("The selection supports only models with base class AbstractStateModel or "
                            "StateElementModel, see handed elements {0}".format(models))
        return models if isinstance(models, set) else set(models)
560828
def is_handler_subclass(cls, classnames=("ViewHandler", "APIHandler")):
    """"""
    if isinstance(cls, list):
        return any(is_handler_subclass(c) for c in cls)
    elif isinstance(cls, type):
        return any(c.__name__ in classnames for c in inspect.getmro(cls))
    else:
        raise TypeError(
            "Unexpected type `{}` for class `{}`".format(
                type(cls),
                cls
            )
        )
837689
public function validateCollectionName()
    {
        if (empty($this->modelClass)) {
            $class = $this->generateClassName($this->collectionName);
            if ($this->isReservedKeyword($class)) {
                $this->addError('collectionName', "Collection '{$this->collectionName}' will generate a class which is a reserved PHP keyword.");
            }
        }
    }
79345
public void clearHandleList() {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (isTracingEnabled && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "Clear the McWrapper handlelist for  the following MCWrapper: " + this);
        }

        // since we know we are only in this method on a destroy or clean up
        // of a MCWrapper ,we can double check that all the handles that this MCWrapper
        // owns are removed from the handlelist on thread local storage before clearing the
        // handlelist in the MCWrapper class.  I tried to be really careful to avoid NPEs
        //
        // Liberty doesn't have real HandleList so don't need to remove anything
        //

        mcwHandleList.clear();

    }
129182
def _is_active_model(cls, model):
        
        # We need to use such tricky way to check because of inconsistent apps names:
        # some apps are included in format "<module_name>.<app_name>" like "waldur_core.openstack"
        # other apps are included in format "<app_name>" like "nodecondcutor_sugarcrm"
        return ('.'.join(model.__module__.split('.')[:2]) in settings.INSTALLED_APPS or
                '.'.join(model.__module__.split('.')[:1]) in settings.INSTALLED_APPS)
839437
protected void cleanCollectionForSave(final RESTBaseEntityCollectionV1<?, ?, ?> collection,
            boolean cleanTopLevel) throws InvocationTargetException,
            IllegalAccessException {
        if (collection == null) return;

        if (cleanTopLevel) {
            collection.removeInvalidChangeItemRequests();
        }

        for (final RESTBaseEntityV1<?> item : collection.returnItems()) {
            cleanEntityForSave(item);
        }
    }
953876
public boolean isSupported(ICalVersion version) {
		for (ICalVersion supportedVersion : supportedVersions) {
			if (supportedVersion == version) {
				return true;
			}
		}
		return false;
	}
128344
private boolean isCollection(@SlashedClassName String className) {
        try {
            JavaClass cls = Repository.lookupClass(className);
            return cls.implementationOf(collectionClass) && !exceptionClasses.contains(cls);
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
            return false;
        }
    }