public void customize()

in sdk/eventgrid/azure-messaging-eventgrid/swagger/src/main/java/EventGridCustomization.java [74:254]


    public void customize(LibraryCustomization customization, Logger logger) {
        customizeEventGridEvent(customization.getPackage("com.azure.messaging.eventgrid.implementation.models")
            .getClass("EventGridEvent"));

        List<ClassCustomization> classCustomizations = customization.getPackage("com.azure.messaging.eventgrid.systemevents")
            .listClasses();

        StringBuilder sb = new StringBuilder();
        List<String> imports = new ArrayList<>();

        Map<String, String> nameMap = new TreeMap<>();
        Map<String, String> classMap = new TreeMap<>();
        Map<String, String> descriptionMap = new TreeMap<>();
        Map<String, String> constantNameMap = new TreeMap<>();

        logger.info("Total number of classes " + classCustomizations.size());

        List<ClassCustomization> eventData = classCustomizations
            .stream()
            .filter(classCustomization -> classCustomization.getClassName().endsWith("EventData"))
            .collect(Collectors.toList());

        List<String> validEventDescription = eventData.stream()
            .filter(classCustomization -> {
                int startIndex =
                    classCustomization.getJavadoc().getDescription().indexOf("Microsoft.");
                int endIndex = classCustomization.getJavadoc().getDescription().lastIndexOf(" event.");
                boolean hasEventName = startIndex > 0 && endIndex > 0;
                if (!hasEventName) {
                    logger.info("Class " + classCustomization.getClassName() + " " + classCustomization.getJavadoc().getDescription());
                }
                return hasEventName;
            })
            .map(classCustomization -> {
                int startIndex =
                    classCustomization.getJavadoc().getDescription().indexOf("Microsoft.");
                int endIndex = classCustomization.getJavadoc().getDescription().indexOf(" ", startIndex);
                String eventName = classCustomization.getJavadoc().getDescription().substring(startIndex, endIndex);
                String className = classCustomization.getClassName();
                String constantName = getReplacementName(getConstantName(className.replace("EventData", "")));

                constantNameMap.put(className, constantName);
                nameMap.put(className, eventName);
                classMap.put(className, className + ".class");
                descriptionMap.put(className, classCustomization.getJavadoc().getDescription());
                imports.add(className);
                return eventName;
            })
            .collect(Collectors.toList());


        Collections.sort(imports);
        sb.append(SYSTEM_EVENT_CLASS_HEADER);

        sb.append("import com.azure.core.models.CloudEvent;");
        sb.append(System.lineSeparator());
        sb.append("import com.azure.messaging.eventgrid.EventGridEvent;");
        sb.append(System.lineSeparator());
        sb.append("import java.util.Collections;");
        sb.append(System.lineSeparator());
        sb.append("import java.util.HashMap;");
        sb.append(System.lineSeparator());
        sb.append("import java.util.Map;");
        sb.append(System.lineSeparator());
        // these two imports are for deprecated events.
        sb.append("import com.azure.messaging.eventgrid.systemevents.AcsChatMemberAddedToThreadWithUserEventData;");
        sb.append(System.lineSeparator());
        sb.append("import com.azure.messaging.eventgrid.systemevents.AcsChatMemberRemovedFromThreadWithUserEventData;");
        sb.append(System.lineSeparator());
        for (String className : imports) {
            sb.append("import com.azure.messaging.eventgrid.systemevents." + className + ";");
            sb.append(System.lineSeparator());
        }
        sb.append(CLASS_DEF);

        for (String className : imports) {
            sb.append("/**");
            sb.append(System.lineSeparator());
            sb.append("* " + descriptionMap.get(className));
            sb.append(System.lineSeparator());
            sb.append("*/");
            sb.append(System.lineSeparator());
            sb.append("public static final String " + constantNameMap.get(className) + " = \"" + nameMap.get(className) +
                "\";");
            sb.append(System.lineSeparator());
            sb.append(System.lineSeparator());
        }
        // Add deprecated events
        sb.append("/**");
        sb.append(System.lineSeparator());
        sb.append(" * @deprecated This event does not exist.");
        sb.append(System.lineSeparator());
        sb.append(" */");
        sb.append(System.lineSeparator());
        sb.append("@Deprecated");
        sb.append(System.lineSeparator());
        sb.append("public static final String COMMUNICATION_CHAT_MEMBER_ADDED_TO_THREAD_WITH_USER =");
        sb.append(System.lineSeparator());
        sb.append("\"Microsoft.Communication.ChatMemberAddedToThreadWithUser\";");
        sb.append(System.lineSeparator());
        sb.append("/**");
        sb.append(System.lineSeparator());
        sb.append(" * @deprecated This event does not exist.");
        sb.append(System.lineSeparator());
        sb.append(" */");
        sb.append(System.lineSeparator());
        sb.append("@Deprecated");
        sb.append(System.lineSeparator());
        sb.append("public static final String COMMUNICATION_CHAT_MEMBER_REMOVED_FROM_THREAD_WITH_USER =");
        sb.append(System.lineSeparator());
        sb.append("\"Microsoft.Communication.ChatMemberRemovedFromThreadWithUser\";");
        sb.append(System.lineSeparator());
        sb.append("/**");
        sb.append(System.lineSeparator());
        sb.append(" * @deprecated As of 4.1.0, replaced by {@link #COMMUNICATION_CHAT_PARTICIPANT_REMOVED_FROM_THREAD}.");
        sb.append(System.lineSeparator());
        sb.append(" */");
        sb.append(System.lineSeparator());
        sb.append("@Deprecated");
        sb.append(System.lineSeparator());
        sb.append("public static final String COMMUNICATION_CHAT_MESSAGE_REMOVED_FROM_THREAD =");
        sb.append(System.lineSeparator());
        sb.append("\"Microsoft.Communication.ChatThreadParticipantRemoved\";");
        sb.append(System.lineSeparator());

        sb.append("/**");
        sb.append(System.lineSeparator());
        sb.append(" * @deprecated As of 4.1.0, replaced by {@link #COMMUNICATION_CHAT_PARTICIPANT_REMOVED_FROM_THREAD_WITH_USER}.");
        sb.append(System.lineSeparator());
        sb.append(" */");
        sb.append(System.lineSeparator());
        sb.append("@Deprecated");
        sb.append(System.lineSeparator());
        sb.append("public static final String COMMUNICATION_CHAT_MESSAGE_REMOVED_FROM_THREAD_WITH_USER =");
        sb.append(System.lineSeparator());
        sb.append("\"Microsoft.Communication.ChatParticipantRemovedFromThreadWithUser\";");
        sb.append(System.lineSeparator());

        sb.append("private static final Map<String, Class<?>> SYSTEM_EVENT_MAPPINGS = new HashMap<String, Class<?>>()" +
            " {{");
        sb.append(System.lineSeparator());

        for (String className : imports) {
            sb.append("put(" + constantNameMap.get(className) + ", " + classMap.get(className) + ");");
            sb.append(System.lineSeparator());
        }
        sb.append("put(COMMUNICATION_CHAT_MESSAGE_REMOVED_FROM_THREAD, AcsChatParticipantRemovedFromThreadEventData.class);");
        sb.append(System.lineSeparator());
        sb.append("put(COMMUNICATION_CHAT_MESSAGE_REMOVED_FROM_THREAD_WITH_USER, AcsChatParticipantRemovedFromThreadWithUserEventData.class);");
        sb.append(System.lineSeparator());
        sb.append("put(COMMUNICATION_CHAT_MEMBER_ADDED_TO_THREAD_WITH_USER, AcsChatMemberAddedToThreadWithUserEventData.class);");
        sb.append(System.lineSeparator());
        sb.append("put(COMMUNICATION_CHAT_MEMBER_REMOVED_FROM_THREAD_WITH_USER, AcsChatMemberRemovedFromThreadWithUserEventData.class);");
        sb.append(System.lineSeparator());
        sb.append("}};");
        sb.append(System.lineSeparator());

        sb.append(PRIVATE_CTOR);

        sb.append("}");
        sb.append(System.lineSeparator());
        logger.info("Total number of events " + eventData.size());
        logger.info("Total number of events with proper description " + validEventDescription.size());

        customization.getRawEditor()
            .addFile("src/main/java/com/azure/messaging/eventgrid/SystemEventNames.java", sb.toString());


        customizeMediaJobOutputAsset(customization);
        customizeStorageDirectoryDeletedEventData(customization);
        customizeAcsRecordingFileStatusUpdatedEventDataDuration(customization);
        customizeMediaLiveEventChannelArchiveHeartbeatEventDataDuration(customization);
        customizeMediaLiveEventIngestHeartbeatEventData(customization);
        customizeResourceEvents(customization, logger);
        customizeEventGridClientImplImports(customization);
        customizeAcsRouterEvents(customization);
        customizeResourceNotificationEvents(customization);
        customizeCommunicationIdentifierModelKind(customization);
        customizeAcsMessageChannelEventError(customization);
        customizeCommuicationSMSEvents(customization);
    }