Code review comment: nit: We should not strictly cast it to ArrayList<String> here, instead keep it open to generic `List<String>` here.   ``` List<String> expandParam = ((Collection<?>) parameters[paramIndex]).stream().map(Object::toString).collect(Collectors.toList()); ```

Code before review:
public Object execute(final Object[] parameters) {
final CosmosParameterAccessor accessor = new CosmosParameterParameterAccessor(getQueryMethod(), parameters);
final ResultProcessor processor = getQueryMethod().getResultProcessor().withDynamicProjection(accessor);
String expandedQuery = query;
List<SqlParameter> sqlParameters = new ArrayList<>();
for (int paramIndex = 0; paramIndex < parameters.length; paramIndex++) {
Parameter queryParam = getQueryMethod().getParameters().getParameter(paramIndex);
if (parameters[paramIndex] instanceof Collection) {
ArrayList<String> expandParam = (ArrayList<String>) ((Collection<?>) parameters[paramIndex]).stream()
.map(Object::toString).collect(Collectors.toList());
List<String> expandedParamKeys = new ArrayList<>();
for (int arrayIndex = 0; arrayIndex < expandParam.size(); arrayIndex++) {
String paramName = "@" + queryParam.getName().orElse("") + arrayIndex;
expandedParamKeys.add(paramName);
sqlParameters.add(new SqlParameter(paramName, toCosmosDbValue(expandParam.get(arrayIndex))));
}
expandedQuery = expandedQuery.replaceAll("@" + queryParam.getName().orElse(""), String.join(",", expandedParamKeys));
} else {
if (!Pageable.class.isAssignableFrom(queryParam.getType())
&& !Sort.class.isAssignableFrom(queryParam.getType())) {
sqlParameters.add(new SqlParameter("@" + queryParam.getName().orElse(""), toCosmosDbValue(parameters[paramIndex])));
}
}
}
SqlQuerySpec querySpec = new SqlQuerySpec(expandedQuery, sqlParameters);
if (isPageQuery()) {
return this.operations.runPaginationQuery(querySpec, accessor.getPageable(), processor.getReturnedType().getDomainType(),
processor.getReturnedType().getReturnedType());
} else if (isSliceQuery()) {
return this.operations.runSliceQuery(
querySpec,
accessor.getPageable(),
processor.getReturnedType().getDomainType(),
processor.getReturnedType().getReturnedType());
} else if (isCountQuery()) {
final String container = ((CosmosEntityMetadata<?>) getQueryMethod().getEntityInformation()).getContainerName();
return this.operations.count(querySpec, container);
} else {
return this.operations.runQuery(querySpec, accessor.getSort(), processor.getReturnedType().getDomainType(),
processor.getReturnedType().getReturnedType());
}
}

Line under review: ArrayList<String> expandParam = (ArrayList<String>) ((Collection<?>) parameters[paramIndex]).stream()

Code after addressing the review:
public Object execute(final Object[] parameters) {
final CosmosParameterAccessor accessor = new CosmosParameterParameterAccessor(getQueryMethod(), parameters);
final ResultProcessor processor = getQueryMethod().getResultProcessor().withDynamicProjection(accessor);
String expandedQuery = query;
List<SqlParameter> sqlParameters = new ArrayList<>();
for (int paramIndex = 0; paramIndex < parameters.length; paramIndex++) {
Parameter queryParam = getQueryMethod().getParameters().getParameter(paramIndex);
if (parameters[paramIndex] instanceof Collection) {
List<String> expandParam = ((Collection<?>) parameters[paramIndex]).stream()
.map(Object::toString).collect(Collectors.toList());
List<String> expandedParamKeys = new ArrayList<>();
for (int arrayIndex = 0; arrayIndex < expandParam.size(); arrayIndex++) {
String paramName = "@" + queryParam.getName().orElse("") + arrayIndex;
expandedParamKeys.add(paramName);
sqlParameters.add(new SqlParameter(paramName, toCosmosDbValue(expandParam.get(arrayIndex))));
}
expandedQuery = expandedQuery.replaceAll("@" + queryParam.getName().orElse(""), String.join(",", expandedParamKeys));
} else {
if (!Pageable.class.isAssignableFrom(queryParam.getType())
&& !Sort.class.isAssignableFrom(queryParam.getType())) {
sqlParameters.add(new SqlParameter("@" + queryParam.getName().orElse(""), toCosmosDbValue(parameters[paramIndex])));
}
}
}
SqlQuerySpec querySpec = new SqlQuerySpec(expandedQuery, sqlParameters);
if (isPageQuery()) {
return this.operations.runPaginationQuery(querySpec, accessor.getPageable(), processor.getReturnedType().getDomainType(),
processor.getReturnedType().getReturnedType());
} else if (isSliceQuery()) {
return this.operations.runSliceQuery(
querySpec,
accessor.getPageable(),
processor.getReturnedType().getDomainType(),
processor.getReturnedType().getReturnedType());
} else if (isCountQuery()) {
final String container = ((CosmosEntityMetadata<?>) getQueryMethod().getEntityInformation()).getContainerName();
return this.operations.count(querySpec, container);
} else {
return this.operations.runQuery(querySpec, accessor.getSort(), processor.getReturnedType().getDomainType(),
processor.getReturnedType().getReturnedType());
}
}