wernerdv commented on code in PR #12554:
URL: https://github.com/apache/ignite/pull/12554#discussion_r2642592740


##########
modules/codegen2/src/main/java/org/apache/ignite/internal/MessageProcessor.java:
##########
@@ -132,9 +138,45 @@ private List<VariableElement> orderedFields(TypeElement 
type) {
                     if (el.getModifiers().contains(Modifier.STATIC)) {
                         processingEnv.getMessager().printMessage(
                             Diagnostic.Kind.ERROR,
-                            "Annotation @Order must be used only for 
non-static fields.",
+                            "Annotation @Order must only be used for 
non-static fields.",
                             el);
                     }
+
+                    CustomMapper custMappAnn = 
el.getAnnotation(CustomMapper.class);
+                    if (enumField(el)) {
+                        String enumClsFullName = el.asType().toString();
+                        String enumMapperClsName = custMappAnn != null ? 
custMappAnn.value() : DLFT_ENUM_MAPPER_CLS;
+                        String msgClsName = type.toString();
+
+                        // Here I put into the map two pieces of information 
about enum mapper:
+                        // message class name where the mapper is used and 
mapper class name itself.
+                        // These names are joined with a colon as a separator 
symbol as it is prohibited in a class name in Java.
+                        String otherMsgAndMapperClassesNames =
+                            enumMappersInUse.put(enumClsFullName, msgClsName + 
':' + enumMapperClsName);
+
+                        if (otherMsgAndMapperClassesNames != null) {
+                            String otherMsgClsName = 
otherMsgAndMapperClassesNames.split(":")[0];
+                            String otherEnumMapperClsName = 
otherMsgAndMapperClassesNames.split(":")[1];
+
+                            if 
(!otherEnumMapperClsName.equals(enumMapperClsName)) {
+                                processingEnv.getMessager().printMessage(
+                                    Diagnostic.Kind.ERROR,
+                                    "Enum " + enumClsFullName + " is declared 
with different mappers: " +
+                                        otherEnumMapperClsName + " in " + 
otherMsgClsName + " and " +
+                                        enumMapperClsName + " in " + 
msgClsName +
+                                        ". Only one mapper is allowed per enum 
type.",
+                                    el);
+                            }
+                        }
+                    }
+                    else {

Review Comment:
   Minor: can be combined into a single `else if` block.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to