You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/02/16 15:14:19 UTC

[GitHub] [ignite-3] SammyVimes opened a new pull request #54: IGNITE-14181 Support arrays of primitives in the configuration schema

SammyVimes opened a new pull request #54:
URL: https://github.com/apache/ignite-3/pull/54


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] ibessonov commented on a change in pull request #54: IGNITE-14181 Support arrays of primitives in the configuration schema

Posted by GitBox <gi...@apache.org>.
ibessonov commented on a change in pull request #54:
URL: https://github.com/apache/ignite-3/pull/54#discussion_r577576450



##########
File path: modules/configuration-annotation-processor/src/main/java/org/apache/ignite/configuration/processor/internal/Processor.java
##########
@@ -901,25 +896,28 @@ private void createPojoBindings(
             String fieldName = field.getSimpleName().toString();
             TypeName schemaFieldType = TypeName.get(field.asType());
 
-            boolean leafField = schemaFieldType.isPrimitive() || !((ClassName)schemaFieldType).simpleName().contains("ConfigurationSchema");
+            boolean isArray = schemaFieldType instanceof ArrayTypeName;
+            boolean isPrimitiveOrArray = isPrimitiveOrArrayOfPrimitives(schemaFieldType);
+
+            boolean leafField = isPrimitiveOrArray || !((ClassName)schemaFieldType).simpleName().contains("ConfigurationSchema");
             boolean namedListField = field.getAnnotation(NamedConfigValue.class) != null;
 
-            TypeName viewFieldType = schemaFieldType.isPrimitive() ? schemaFieldType : ClassName.get(
+            TypeName viewFieldType = isPrimitiveOrArray ? schemaFieldType : ClassName.get(

Review comment:
       Please replace it with "leafField"

##########
File path: modules/configuration-annotation-processor/src/main/java/org/apache/ignite/configuration/processor/internal/Processor.java
##########
@@ -1339,6 +1358,31 @@ public MethodSpec createChangeMethod(TypeName type, List<VariableElement> variab
             .build();
     }
 
+    /**
+     * Checks whether TypeName is a primitive (or String) or an array of primitives (or Strings)
+     * @param typeName TypeName.
+     * @return {@code true} if type is primitive or array.
+     */
+    private boolean isPrimitiveOrArrayOfPrimitives(TypeName typeName) {
+        String type = typeName.toString();
+
+        if (typeName instanceof ArrayTypeName)
+            type = ((ArrayTypeName) typeName).componentType.toString();
+
+        switch (type) {
+            case "boolean":
+            case "int":
+            case "long":
+            case "double":
+            case "java.lang.String":
+                return true;
+
+            default:
+                return false;
+

Review comment:
       What's the purpose of this extra line?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] SammyVimes commented on a change in pull request #54: IGNITE-14181 Support arrays of primitives in the configuration schema

Posted by GitBox <gi...@apache.org>.
SammyVimes commented on a change in pull request #54:
URL: https://github.com/apache/ignite-3/pull/54#discussion_r578377267



##########
File path: modules/configuration-annotation-processor/src/main/java/org/apache/ignite/configuration/processor/internal/Processor.java
##########
@@ -1339,6 +1358,31 @@ public MethodSpec createChangeMethod(TypeName type, List<VariableElement> variab
             .build();
     }
 
+    /**
+     * Checks whether TypeName is a primitive (or String) or an array of primitives (or Strings)
+     * @param typeName TypeName.
+     * @return {@code true} if type is primitive or array.
+     */
+    private boolean isPrimitiveOrArrayOfPrimitives(TypeName typeName) {
+        String type = typeName.toString();
+
+        if (typeName instanceof ArrayTypeName)
+            type = ((ArrayTypeName) typeName).componentType.toString();
+
+        switch (type) {
+            case "boolean":
+            case "int":
+            case "long":
+            case "double":
+            case "java.lang.String":
+                return true;
+
+            default:
+                return false;
+

Review comment:
       Codestyle :)




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] ibessonov merged pull request #54: IGNITE-14181 Support arrays of primitives in the configuration schema

Posted by GitBox <gi...@apache.org>.
ibessonov merged pull request #54:
URL: https://github.com/apache/ignite-3/pull/54


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org