@SuppressWarnings("unchecked")
    private void addEndpointsTags(JsonArray tagsArray) throws IOException {
        if (registeredHandlers == null || registeredHandlers.isEmpty()) {
            return;
        }
        TreeSet<String> handlerNamesSorted = new TreeSet<>(registeredHandlers.keySet());
        handlerNamesSorted.forEach(key -> {
            StringBuilder sb = new StringBuilder();
            sb.append("{\"name\":\"");
            sb.append(key);
            sb.append("\",\"request\":{\"name\":\"");
            try {
                ServiceMethodHandler handler = registeredHandlers.get(key);
                Class<? extends Message> requestClass = (Class<? extends Message>)
                        findSubClassParameterType(handler, 0);
                Class<? extends Message> responseClass = (Class<? extends Message>)
                        findSubClassParameterType(handler, 1);
                sb.append(requestClass.getSimpleName());
                sb.append("\",\"type\":\"");
                sb.append(requestClass.getSimpleName());
                sb.append("\",\"values\":[");
                sb.append(getProtobufClassFieldDescriptions(requestClass, new HashSet<>()));
                sb.append("]},\"response\":{\"name\":\"");
                sb.append(responseClass.getSimpleName());
                sb.append("\",\"type\":\"");
                sb.append(responseClass.getSimpleName());
                sb.append("\",\"values\":[");
                sb.append(getProtobufClassFieldDescriptions(responseClass, new HashSet<>()));
                sb.append("]},\"metadata\":{\"stream\":\"false\"}}");
            } catch (Exception e) {
                logger.error("Error inspecting handlers", e);
                return;
            }
            String tag = sb.toString();
            tagsArray.add(new JsonPrimitive("e-" + binaryEncode(tag)));
        });
    }
By Brian, 2019-08-13 15:13:37