private function getGroupsForItemAndCollectionOperation(ResourceMetadata $resourceMetadata, string $operationName, string $io): array
    {
        $operation = $this->getGroupsContext($resourceMetadata, $operationName, true);
        $operation += $this->getGroupsContext($resourceMetadata, $operationName, false);

        if (self::OUT_PREFIX === $io) {
            return [
                'serializer_groups' => !empty($operation['normalization_context']) ? $operation['normalization_context'][AbstractNormalizer::GROUPS] : [],
            ];
        }

        if (self::IN_PREFIX === $io) {
            return [
                'serializer_groups' => !empty($operation['denormalization_context']) ? $operation['denormalization_context'][AbstractNormalizer::GROUPS] : [],
            ];
        }

        return [];
    }