private static void addMessage(final String[] codes, final RequestContext requestContext, final Severity severity) {
        Arrays.stream(codes).forEach(code -> {
            val message = switch (severity) {
                case INFO -> new MessageBuilder().info().code(code).build();
                case FATAL, ERROR -> new MessageBuilder().error().code(code).build();
                case WARNING -> new MessageBuilder().warning().code(code).build();
            };
            requestContext.getMessageContext().addMessage(message);
        });
    }
This is {@link PopulateMessageContextAction}.

@author Misagh Moayyed
@since 7.0.0
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/actions/PopulateMessageContextAction.java