A field of type Collection<Collection> cannot be marshalled into bigquery data format as
parameterized types nested more than one level cannot be determined at runtime. So cannot be
marshalled.
961093
public static void validateNestedRepeatedType(Class<?> parameterType, Field field) {
    if (isCollectionOrArray(parameterType)) {
      throw new IllegalArgumentException(
          " Cannot marshal a nested collection or array field " + field.getName());
    }
  }
144308
public <R, RK> List<R> fetch(Collection<DBRef<R, RK>> collection, DBObject fields) {
        Map<JacksonCollectionKey, List<Object>> collectionsToIds = new HashMap<JacksonCollectionKey, List<Object>>();
        for (DBRef<R, RK> ref : collection) {
            if (ref instanceof FetchableDBRef) {
                JacksonCollectionKey key = ((FetchableDBRef) ref).getCollectionKey();
                List<Object> ids = collectionsToIds.get(key);
                if (ids == null) {
                    ids = new ArrayList<Object>();
                    collectionsToIds.put(key, ids);
                }
                ids.add(getReferenceCollection(key).convertToDbId(ref.getId()));
            }
        }
        List<R> results = new ArrayList<R>();
        for (Map.Entry<JacksonCollectionKey, List<Object>> entry : collectionsToIds.entrySet()) {
            for (R result : this.<R, RK>getReferenceCollection(entry.getKey()).find(
                    new QueryBuilder().put("_id").in(entry.getValue()).get(), fields)) {
                results.add(result);
            }
        }
        return results;
    }
347515
@Override
    public Map<String, FieldTypes> get(final Collection<String> fieldNames) {
        return get(fieldNames, ImmutableSet.of());
    }
567273
function _validateSerializedArray(collection) {
  if (!Array.isArray(collection)) {
    throw new TypeError(collection + ' is not an array.');
  }

  if (collection.length === 0) {
    throw new Error(collection + ' is empty.');
  }

  if (collection[0].hasOwnProperty('name')) {
    if (typeof collection[0].name !== 'string') {
      throw new TypeError(
        'Invalid value type passed for name of option ' +
          collection[0].name +
          '. Value should be string.'
      );
    }
  } else {
    throw new Error(collection[0] + 'does not contain name key.');
  }
}
475552
private static Object generateValue(Field field) {
    Class<?> rawType = field.getType();

    //TODO Objects other than Lists might need parametrized types.
    if (List.class.isAssignableFrom(rawType)) {
      ParameterizedType genericType = (ParameterizedType) field.getGenericType();
      return createListObject(genericType);
    }

    return generateValue(rawType);
  }
817726
private Map<SchemaTable, List<Multimap<BiPredicate, RecordId>>> groupIdsBySchemaTable() {
        Map<SchemaTable, List<Multimap<BiPredicate, RecordId>>> result = new HashMap<>();
        for (HasContainer idHasContainer : this.idHasContainers) {

            Map<SchemaTable, Boolean> newHasContainerMap = new HashMap<>();
            @SuppressWarnings("unchecked")
            P<Object> idPredicate = (P<Object>) idHasContainer.getPredicate();
            BiPredicate biPredicate = idHasContainer.getBiPredicate();
            //This is statement is for g.V().hasId(Collection) where the logic is actually P.within not P.eq
            if (biPredicate == Compare.eq && idPredicate.getValue() instanceof Collection && ((Collection) idPredicate.getValue()).size() > 1) {
                biPredicate = Contains.within;
            }
            Multimap<BiPredicate, RecordId> biPredicateRecordIdMultimap;
            if (idPredicate.getValue() instanceof Collection) {

                @SuppressWarnings("unchecked")
                Collection<Object> ids = (Collection<Object>) idPredicate.getValue();
                for (Object id : ids) {
                    RecordId recordId = RecordId.from(id);
                    List<Multimap<BiPredicate, RecordId>> biPredicateRecordIdList = result.get(recordId.getSchemaTable());
                    Boolean newHasContainer = newHasContainerMap.get(recordId.getSchemaTable());
                    if (biPredicateRecordIdList == null) {
                        biPredicateRecordIdList = new ArrayList<>();
                        biPredicateRecordIdMultimap = LinkedListMultimap.create();
                        biPredicateRecordIdList.add(biPredicateRecordIdMultimap);
                        result.put(recordId.getSchemaTable(), biPredicateRecordIdList);
                        newHasContainerMap.put(recordId.getSchemaTable(), false);
                    } else if (newHasContainer == null) {
                        biPredicateRecordIdMultimap = LinkedListMultimap.create();
                        biPredicateRecordIdList.add(biPredicateRecordIdMultimap);
                        newHasContainerMap.put(recordId.getSchemaTable(), false);
                    }
                    biPredicateRecordIdMultimap = biPredicateRecordIdList.get(biPredicateRecordIdList.size() - 1);
                    biPredicateRecordIdMultimap.put(biPredicate, recordId);
                }
            } else {
                Object id = idPredicate.getValue();
                RecordId recordId = RecordId.from(id);
                List<Multimap<BiPredicate, RecordId>> biPredicateRecordIdList = result.computeIfAbsent(recordId.getSchemaTable(), k -> new ArrayList<>());
                biPredicateRecordIdMultimap = LinkedListMultimap.create();
                biPredicateRecordIdList.add(biPredicateRecordIdMultimap);
                biPredicateRecordIdMultimap.put(biPredicate, recordId);
            }
        }
        return result;
    }
121533
function hasField(selection, fieldNames) {
  if (!selection || selection.type === 'empty') {
    return false;
  }
  const fieldsToLookup = [].concat(fieldNames);

  if (selection.type === 'range') {
    const fields = Object.keys(selection.range.variables);
    const match = intersect(fieldsToLookup, fields);
    return match.length > 0;
  }
  if (selection.type === 'partition') {
    return fieldsToLookup.indexOf(selection.partition.variable) !== -1;
  }

  console.log(
    'SelectionBuilder::hasField does not handle selection of type',
    selection.type
  );

  return false;
}
917081
public static Collection getEmbeddedCollectionInstance(Field embeddedCollectionField)
    {
        Collection embeddedCollection = null;
        Class embeddedCollectionFieldClass = embeddedCollectionField.getType();

        if (embeddedCollection == null || embeddedCollection.isEmpty())
        {
            if (embeddedCollectionFieldClass.equals(List.class))
            {
                embeddedCollection = new ArrayList<Object>();
            }
            else if (embeddedCollectionFieldClass.equals(Set.class))
            {
                embeddedCollection = new HashSet<Object>();
            }
            else
            {
                throw new InvalidEntityDefinitionException("Field " + embeddedCollectionField.getName()
                        + " must be either instance of List or Set");
            }
        }
        return embeddedCollection;
    }
266223
private ImmutableList<TermType> inferCastTypes(
            Predicate predicate, Collection<CQIE> samePredicateRules,
            ImmutableMap<CQIE, ImmutableList<Optional<TermType>>> termTypeMap,
            Map<Predicate, ImmutableList<TermType>> alreadyKnownCastTypes, DBMetadata metadata) {

        if (samePredicateRules.isEmpty()) {

            ImmutableList.Builder<TermType> defaultTypeBuilder = ImmutableList.builder();

            RelationID tableId = relation2Predicate.createRelationFromPredicateName(metadata.getQuotedIDFactory(), predicate);
            Optional<RelationDefinition> td = Optional.ofNullable(metadata.getRelation(tableId));

            IntStream.range(0, predicate.getArity())
                    .forEach(i -> {

                        if(td.isPresent()) {
                            Attribute attribute = td.get().getAttribute(i+1);

                            //get type from metadata
                            defaultTypeBuilder.add(attribute.getTermType());
                        }
                        else{
                            defaultTypeBuilder.add(literalType);
                        }});
            return defaultTypeBuilder.build();
        }

        ImmutableMultimap<Integer, TermType> collectedProposedCastTypes = collectProposedCastTypes(
                samePredicateRules, termTypeMap, alreadyKnownCastTypes);

        return collectedProposedCastTypes.keySet().stream()
                // 0 to n
                .sorted()
                .map(i -> collectedProposedCastTypes.get(i).stream()
                            .reduce(
                                    // Neutral
                                    null,
                                    (type1, type2) -> type1 == null ? type2 : unifyCastTypes(type1, type2)))
                .map(type -> {
                    if (type != null) {
                        return type;
                    }
                    throw new IllegalStateException("Every argument is expected to have a COL_TYPE");
                })
                .collect(ImmutableCollectors.toList());
    }
843169
function validateFieldType(fieldsCollection){
        var err;

        // ensure fieldsCollection is an array.
        if(!_.isArray(fieldsCollection)) {
            err = new Error('content type fields collection must be an array of field objects.');
        }

        if(!err) {
            _.each(fieldsCollection, function(field){
                err = isValidField(field);
            });
        }

        return _.isUndefined(err);
    }
611480
private void appendCollectionTypeField(JField field, PDescriptor descriptor) {
        switch (descriptor.getType()) {
            case BYTE:
            case BINARY:
                writer.formatln(".addByteArrayField(\"%s\")", field.name());
                break;
            case BOOL:
                writer.formatln(".addBooleanArrayField(\"%s\")", field.name());
                break;
            case DOUBLE:
                writer.formatln(".addDoubleArrayField(\"%s\")", field.name());
                break;
            case I16:
                writer.formatln(".addShortArrayField(\"%s\")", field.name());
                break;
            case I32:
            case ENUM:
                writer.formatln(".addIntArrayField(\"%s\")", field.name());
                break;
            case I64:
                writer.formatln(".addLongArrayField(\"%s\")", field.name());
                break;
            case STRING:
                writer.formatln(".addUTFArrayField(\"%s\")", field.name());
                break;
            case MESSAGE:
                writer.formatln(".addPortableArrayField(\"%s\", %s(%s))",
                                field.name(),
                                camelCase("get", descriptor.getName() + "Definition"),
                                PORTABLE_VERSION);
                break;
            default:
                throw new GeneratorException(
                        "Not implemented appendCollectionTypeField for list with type: " + descriptor.getType() + " in " +
                        this.getClass()
                            .getSimpleName());
        }
    }
1223173
private static int[] makeFields(int[] fields, TupleTypeInfo<?> type) {
		int inLength = type.getArity();
		
		// null parameter means all fields are considered
		if (fields == null || fields.length == 0) {
			fields = new int[inLength];
			for (int i = 0; i < inLength; i++) {
				fields[i] = i;
			}
			return fields;
		} else {
			return rangeCheckAndOrderFields(fields, inLength-1);
		}
	}
141057
@Override
	public <L extends Collection<E>> L parseCollection(BinderContext context, ParserWrapper parserWrapper, L collection)  throws Exception {
		switch (context.getSupportedFormat()) {
		case XML: {
			throw (new KriptonRuntimeException(context.getSupportedFormat() + " context does not support direct collection persistance"));
		}
		default: {
			JacksonWrapperParser wrapperParser = (JacksonWrapperParser) parserWrapper;
			JsonParser parser = wrapperParser.jacksonParser;

			try {
				collection.clear();

				if (parser.nextToken() != JsonToken.START_ARRAY) {
					throw (new KriptonRuntimeException("Invalid input format"));
				}
				if (context.getSupportedFormat().onlyText) {
					while (parser.nextToken() != JsonToken.END_ARRAY) {
						collection.add(parseOnJacksonAsString(parser));
					}
				} else {
					while (parser.nextToken() != JsonToken.END_ARRAY) {
						collection.add(parseOnJackson(parser));
					}
				}
				return collection;
			} catch (IOException e) {
				e.printStackTrace();
				throw (new KriptonRuntimeException(e));
			}
		}
		}
	}
82523
public void ensureCollection(StructuredType entityType) throws ODataException {
        List<String> missingCollectionPropertyName = new ArrayList<>();

        entityType.getStructuralProperties().stream()
                .filter(property -> (property.isCollection())
                        && !(property instanceof NavigationProperty) && !property.isNullable()).forEach(property -> {
            LOG.debug("Validating non-nullable collection property : {}", property.getName());
            if (!fields.containsKey(property.getName())) {
                missingCollectionPropertyName.add(property.getName());
            }
        });
        if (missingCollectionPropertyName.size() != 0) {
            StringJoiner joiner = new StringJoiner(",");
            missingCollectionPropertyName.forEach(joiner::add);
            throw new ODataUnmarshallingException("The request does not specify the non-nullable collections: '"
                    + joiner.toString() + ".");
        }

    }
260734
def array_type(data_types, field):
    
    from sqlalchemy.dialects import postgresql

    internal_type = field.base_field.get_internal_type()

    # currently no support for multi-dimensional arrays
    if internal_type in data_types and internal_type != 'ArrayField':
        sub_type = data_types[internal_type](field)
        if not isinstance(sub_type, (list, tuple)):
            sub_type = [sub_type]
    else:
        raise RuntimeError('Unsupported array element type')

    return postgresql.ARRAY(sub_type)
666322
private Object resolvePropertyTypedValue(FieldData field) {
        Object value;
        if (field.metaData.isInstantiableCollectionType()) {
            value = getArrayPropertyAsCollection(field);
        } else {
            value = resolvePropertyTypedValue(field, field.metaData.getType());
        }
        return value;
    }
681828
protected void handleCollectionTypeNotAvailable(XCollectionLiteral literal, ITypeComputationState state, Class<?> clazz) {
		for(XExpression element: literal.getElements()) {
			state.withNonVoidExpectation().computeTypes(element);
		}
		state.acceptActualType(state.getReferenceOwner().newUnknownTypeReference(clazz.getName()));
	}