class TagHelper {

    public void executeFunctionForTagEntities(final String indexName, final List<TagEntity> tagEntities,
        final TriConsumer<String, String, String> function)
    {
        // For each tag apply the passed in function
        tagEntities.forEach(tagEntity -> {
            // Fetch Join with .size()
            tagEntity.getChildrenTagEntities().size();

            // Convert the tag entity to a JSON string
            final String jsonString = safeObjectMapperWriteValueAsString(tagEntity);

            if (StringUtils.isNotEmpty(jsonString))
            {
                // Call the function that will process each tag entity against the index
                try
                {
                    function.accept(indexName, tagEntity.getId().toString(), jsonString);
                }
                catch (Exception ex)
                {
                    LOGGER.warn("Index operation exception is logged {} for {}, {}, {}", ex, indexName, tagEntity.getId().toString(), jsonString);
                }
            }
        });

        LOGGER.info("Finished processing {} tags with a search index function.", tagEntities.size());
    }

}