The typed collection type. Contains only elements of the
supplied class.

@see ITypedCollection

@param IType  $elementType
@param string $collectionClass

@return CollectionType
88
public static function collectionOf(IType $elementType, string $collectionClass = ITypedCollection::class) : CollectionType
    {
        $elementTypeString = $elementType->asTypeString();

        if (!isset(self::$collections[$collectionClass][$elementTypeString])) {
            self::$collections[$collectionClass][$elementTypeString] = new CollectionType($elementType, $collectionClass);
        }

        return self::$collections[$collectionClass][$elementTypeString];
    }
805844
protected function getElementQuery($elementType, array $criteria): ElementQueryInterface
    {
        /** @var string|ElementInterface $elementType */
        $query = $elementType::find();
        Craft::configure($query, $criteria);

        return $query;
    }
404463
function(name, collection) {
			if (!elementTypes[collection])
				elementTypes[collection] = [];
			
			var col = this.getCollection(collection);
			if (!~col.indexOf(name)) {
				col.push(name);
			}
		}
1149892
public static <T> Function<Object, Collection<T>> COLLECTION(final Class<? extends Collection> collectionType, final Class<T> componentType) {
      return new CollectionConverterImpl<>(collectionType, componentType);
   }
67706
public function mapToCollection(CollectionType $collectionType, callable $mapperCallback = null, callable $reverseMapperCallback = null)
    {
        $collectionClass = $collectionType->getCollectionClass();

        if ($collectionClass === TypedCollection::class || $collectionClass === ITypedCollection::class) {
            $collectionFactory = function (array $input) use ($collectionType) {
                return new TypedCollection($collectionType->getElementType(), $input);
            };
        } elseif ($collectionClass === EntityIdCollection::class) {
            $collectionFactory = function (array $input) use ($collectionType) {
                return new EntityIdCollection($input);
            };
        } elseif ($collectionType->isSubsetOf(TypedObject::collectionType())) {
            $objectType = $collectionType->getElementType()->asTypeString();
            $collectionFactory = function (array $input) use ($objectType) {
                /** @var string|TypedObject $objectType */
                return $objectType::collection($input);
            };
        } else {
            throw InvalidArgumentException::format(
                'Invalid collection type supplied to %s: expecting one of (%s), %s given',
                get_class($this) . '::' . __FUNCTION__,
                Debug::formatValues([TypedCollection::class, EntityIdCollection::class, TypedObject::collectionType()->asTypeString()]),
                $collectionType->asTypeString()
            );
        }

        $this->customProcessorCallbacks[] = function (IType $currentType) use (
            $collectionType,
            $collectionFactory,
            $mapperCallback,
            $reverseMapperCallback
        ) {
            return new CustomProcessor(
                $currentType->isNullable() ? $collectionType->nullable() : $collectionType,
                function (array $elements) use ($collectionFactory, $mapperCallback) {
                    $elements = $mapperCallback ? array_map($mapperCallback, $elements) : $elements;

                    return $collectionFactory($elements);
                },
                function (ITypedCollection $collection) use ($collectionType, $reverseMapperCallback) {
                    $elements = [];

                    foreach ($collection as $key => $element) {
                        $elements[$key] = $element;
                    }

                    return $reverseMapperCallback ? array_map($reverseMapperCallback, $elements) : $elements;
                }
            );
        };

        return $this;
    }
401132
public static boolean isODataEntityCollectionType(Class<?> type,
            Type genericType) {
        if (ListResult.class != type) {
            return false;
        }

        ParameterizedType pt = (ParameterizedType) genericType;

        if (pt.getActualTypeArguments().length != 1) {
            return false;
        }

        Class<?> typeClass = getCollectedType(genericType);

        return isODataEntityType(typeClass);
    }
1012165
public static <T> TypeChecker<Queue<? extends T>> tQueue(TypeChecker<? extends T> elementChecker) {
        return new CollectionTypeChecker<>(Queue.class, elementChecker);
    }
874249
protected function loadCollection($collectionId)
    {
        $collection = $this->ezInfoCollectionRepository->findOneBy(['id' => $collectionId]);

        $content = $this->contentService->loadContent($collection->getContentObjectId());

        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
        $definitionsById = $contentType->fieldDefinitionsById;

        $collections = $this->ezInfoCollectionAttributeRepository->findBy(
            [
                'informationCollectionId' => $collectionId,
            ]
        );

        $attributes = [];
        /** @var EzInfoCollectionAttribute $coll */
        foreach ($collections as $coll) {

            if (empty($definitionsById[$coll->getContentClassAttributeId()])) {
                continue;
            }

            $attributes[] = new Attribute([
                'entity' => $coll,
                'field' => $definitionsById[$coll->getContentClassAttributeId()],
            ]);

        }

        return new Collection([
            'entity' => $collection,
            'attributes' => $attributes,
            'user' => $this->getUser($collection->getCreatorId()),
            'content' => $content,
        ]);
    }
738248
public function withErrors(array $errors = []): CollectionElement
    {
        $this->allErrors = $errors;

        array_walk(
            $this->elements,
            function (ElementInterface $element) use ($errors) {
                $name = $element->name();
                if (isset($errors[$name]) && $element instanceof ErrorAwareInterface) {
                    $element->withErrors($errors);
                    unset($errors[$name]);
                }
            }
        );

        // assign errors without matches to the collection itself.
        $this->errors = $errors;

        return $this;
    }
852562
public static ClassNode inferLoopElementType(final ClassNode collectionType) {
        ClassNode componentType = collectionType.getComponentType();
        if (componentType == null) {
            if (implementsInterfaceOrIsSubclassOf(collectionType, ITERABLE_TYPE)) {
                ClassNode intf = GenericsUtils.parameterizeType(collectionType, ITERABLE_TYPE);
                GenericsType[] genericsTypes = intf.getGenericsTypes();
                componentType = genericsTypes[0].getType();
            } else if (implementsInterfaceOrIsSubclassOf(collectionType, MAP_TYPE)) {
                // GROOVY-6240
                ClassNode intf = GenericsUtils.parameterizeType(collectionType, MAP_TYPE);
                GenericsType[] genericsTypes = intf.getGenericsTypes();
                componentType = MAP_ENTRY_TYPE.getPlainNodeReference();
                componentType.setGenericsTypes(genericsTypes);
            } else if (STRING_TYPE.equals(collectionType)) {
                componentType = ClassHelper.STRING_TYPE;
            } else if (ENUMERATION_TYPE.equals(collectionType)) {
                // GROOVY-6123
                ClassNode intf = GenericsUtils.parameterizeType(collectionType, ENUMERATION_TYPE);
                GenericsType[] genericsTypes = intf.getGenericsTypes();
                componentType = genericsTypes[0].getType();
            } else {
                componentType = ClassHelper.OBJECT_TYPE;
            }
        }
        return componentType;
    }
639989
public static <T> TypeChecker<Collection<? extends T>> tCollection(Class<? extends T> elementType) {
        return tCollection(tSimple(elementType));
    }
696656
protected static function getClassFromCollection( array $collection )
    {
        // Make sure everything in this container is of __exactly__ the same type.
        // This is a stronger check than the entity container performs (child entities are ok in the container)
        $classes = array_unique( array_map( 'get_class', $collection ) );

        if( count( $classes ) > 1 ) {
            // TODO this could fallback to persisting every entity individually. That would work.
            throw new \Exception(
                sprintf(
                    "Can't manage entities in a container with multiple types, these are %s.",
                    implode( ", ", $classes )
                )
            );
        }
        return array_pop( $classes );

    }
303057
protected Class<?> defineCollectionClass(ParameterizedTypeName collectionTypeName) {
		if (collectionTypeName.rawType.toString().startsWith(collectionClazz.getCanonicalName())) {
			return defaultClazz;
		} else if (collectionTypeName.rawType.toString().startsWith(SortedMap.class.getCanonicalName())) {
			return TreeMap.class;
		} else if (collectionTypeName.rawType.toString().startsWith(SortedSet.class.getCanonicalName())) {
			return TreeSet.class;
		}
		try {
			return Class.forName(collectionTypeName.rawType.toString());
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new KriptonClassNotFoundException(e);
		}
	}
235802
public static Class<? extends AbstractElement<?, ?>> toElementClass(SegmentType elementType) {
        switch (elementType) {
            case t:
                return Tenant.class;
            case e:
                return Environment.class;
            case f:
                return Feed.class;
            case m:
                return Metric.class;
            case mt:
                return MetricType.class;
            case r:
                return Resource.class;
            case rt:
                return ResourceType.class;
             case rl:
                return Relationship.class;
            case d:
                return DataEntity.class;
            case ot:
                return OperationType.class;
            case mp:
                return MetadataPack.class;
            default:
                throw new IllegalStateException("There is no " + Entity.class.getName() + " type for " +
                        elementType.getClass().getName() + " '" + elementType.name() + "'");
        }
    }
552931
private function getObjectClass(ICollection $collection, IObjectType $objectType)
    {
        if (null != ($objectClass = $objectType->getObjectClass())) {
            return $objectClass;
        } elseif ($collection instanceof IHierarchicCollection || $collection instanceof ICommonHierarchy) {
            return $this->defaultHierarchicObjectClass;
        } else {
            return $this->defaultObjectClass;
        }
    }
522231
public function getPropertyType() {
    if ($this->valueType === self::COLLECTION_VALUED) {
      return new PersistentCollectionType($this->gClass);
    } else {
      return new EntityType($this->gClass);
    }
  }
51352
public <T> Object convert(Class collectionType, Class<T> elementType, String origin) throws ConversionException {
        Converter<T> elementConverter = find(elementType);
        CollectionConverter<T> converter = new CollectionConverter<>(elementConverter, stringSplitter);

        try {
            Collection<T> converted = converter.convert(origin);
            return castCollectionToType(collectionType, converted);
        } catch (Exception e) {
            throw new ConversionException(String.format("Could not convert string <%s> to collection <%s> " +
                    "with element type <%s>", origin, collectionType, elementType), e);
        }
    }