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


##########
modules/core/src/test/resources/codegen/EnumFieldsMessage.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.internal.processors.cache.GridCacheOperation;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+public class EnumFieldsMessage implements Message {
+    @Order(0)
+    private TransactionIsolation publicEnum;

Review Comment:
   Let's enforce user to specify mapping - default, or external



##########
modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/mappers/DefaultEnumMapper.java:
##########
@@ -15,24 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal;
+package org.apache.ignite.plugin.extensions.communication.mappers;
 
-import org.apache.ignite.plugin.extensions.communication.Message;
-import org.apache.ignite.transactions.TransactionIsolation;
+/** */
+public class DefaultEnumMapper<T extends Enum<T>> implements EnumMapper<T> {
+    /** */
+    private final T[] enumVals;
 
-public class UnwrappedEnumFieldMessage implements Message {
-    @Order(0)
-    private TransactionIsolation isolation;
-
-    public TransactionIsolation isolation() {
-        return isolation;
+    /** */
+    public DefaultEnumMapper(T[] vals) {

Review Comment:
   No need to instantiate a new mapper for every enum. The approach below can 
be inlined into MessageGenerator instead of creating a new class
   
   ```
   public <T extends Enum<T>> byte encode(T enumVal) {
       return (byte)enumVal.ordinal();
   }
   
   public <T extends Enum<T>> T decode(Class<T> enumCls, byte enumCode) {
       return enumCls.getEnumConstants()[enumCode];
   }
   ```



-- 
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