class BusinessObjectDefinitionDescriptionSuggestionChangeMessageBuilder extends AbstractNotificationMessageBuilder implements NotificationMessageBuilder {

    @Override
    @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification =
        "The NotificationEvent is cast to a BusinessObjectDefinitionDescriptionSuggestionChangeNotificationEvent which is always the case since" +
            " we manage the event type to a builder in a map defined in NotificationMessageManager")
    public Map<String, Object> getNotificationMessageVelocityContextMap(NotificationEvent notificationEvent)
    {
        BusinessObjectDefinitionDescriptionSuggestionChangeNotificationEvent event =
            (BusinessObjectDefinitionDescriptionSuggestionChangeNotificationEvent) notificationEvent;

        // Create a list of users (User IDs) that need to be notified about this event.
        // Initialize the list with the user who created this business object definition description suggestion.
        List<String> notificationList = new ArrayList<>();
        notificationList.add(event.getBusinessObjectDefinitionDescriptionSuggestion().getCreatedByUserId());

        NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(event.getNamespace());
        Assert.notNull(namespaceEntity, String.format("namespaceEntity must not be null for namespace code \"%s\"", event.getNamespace()));

        // Add to the notification list all users that have WRITE or WRITE_DESCRIPTIVE_CONTENT permission on the namespace.
        notificationList.addAll(userNamespaceAuthorizationDao.getUserIdsWithWriteOrWriteDescriptiveContentPermissionsByNamespace(namespaceEntity));

        // Create JSON and XML escaped copies of the business object definition description suggestion.
        BusinessObjectDefinitionDescriptionSuggestion businessObjectDefinitionDescriptionSuggestionWithJson =
            escapeJsonBusinessObjectDefinitionDescriptionSuggestion(event.getBusinessObjectDefinitionDescriptionSuggestion());
        BusinessObjectDefinitionDescriptionSuggestion businessObjectDefinitionDescriptionSuggestionWithXml =
            escapeXmlBusinessObjectDefinitionDescriptionSuggestion(event.getBusinessObjectDefinitionDescriptionSuggestion());

        // Create JSON and XML escaped notification lists.
        List<String> notificationListWithJson = new ArrayList<>();
        List<String> notificationListWithXml = new ArrayList<>();
        for (String userId : notificationList)
        {
            notificationListWithJson.add(escapeJson(userId));
            notificationListWithXml.add(escapeXml(userId));
        }

        // Create a context map of values that can be used when building the message.
        Map<String, Object> velocityContextMap = new HashMap<>();
        addObjectPropertyToContext(velocityContextMap, "businessObjectDefinitionDescriptionSuggestion",
            event.getBusinessObjectDefinitionDescriptionSuggestion(), businessObjectDefinitionDescriptionSuggestionWithJson,
            businessObjectDefinitionDescriptionSuggestionWithXml);
        addObjectPropertyToContext(velocityContextMap, "businessObjectDefinitionDescriptionSuggestionKey",
            event.getBusinessObjectDefinitionDescriptionSuggestion().getBusinessObjectDefinitionDescriptionSuggestionKey(),
            businessObjectDefinitionDescriptionSuggestionWithJson.getBusinessObjectDefinitionDescriptionSuggestionKey(),
            businessObjectDefinitionDescriptionSuggestionWithXml.getBusinessObjectDefinitionDescriptionSuggestionKey());
        addStringPropertyToContext(velocityContextMap, "lastUpdatedByUserId", event.getLastUpdatedByUserId());
        velocityContextMap.put("lastUpdatedOn", event.getLastUpdatedOn());
        addObjectPropertyToContext(velocityContextMap, "notificationList", notificationList, notificationListWithJson, notificationListWithXml);
        addStringPropertyToContext(velocityContextMap, "namespace", event.getNamespace());

        // Return the Velocity context map.
        return velocityContextMap;
    }

}