tkalkirill commented on a change in pull request #602:
URL: https://github.com/apache/ignite-3/pull/602#discussion_r798291995



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/util/ArrayUtils.java
##########
@@ -57,155 +58,137 @@
     public static final Object[] OBJECT_EMPTY_ARRAY = new Object[0];
 
     /** {@code byte} array factory. */
-    public static final ArrayFactory<byte[]> BYTE_ARRAY = new ArrayFactory<>() 
{
-        @Override
-        public byte[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid byte array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return BYTE_EMPTY_ARRAY;
-
-                default:
-                    return new byte[len];
-            }
+    public static final ArrayFactory<byte[]> BYTE_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid byte array length: 
" + len);
+        }
+
+        switch (len) {
+            case 0:
+                return BYTE_EMPTY_ARRAY;
+
+            default:
+                return new byte[len];
         }
     };
 
     /** {@code short} array factory. */
-    public static final ArrayFactory<short[]> SHORT_ARRAY = new 
ArrayFactory<>() {
-        @Override
-        public short[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid short array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return SHORT_EMPTY_ARRAY;
-
-                default:
-                    return new short[len];
-            }
+    public static final ArrayFactory<short[]> SHORT_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid short array 
length: " + len);
+        }
+
+        switch (len) {
+            case 0:
+                return SHORT_EMPTY_ARRAY;
+
+            default:
+                return new short[len];
         }
     };
 
     /** {@code int} array factory. */
-    public static final ArrayFactory<int[]> INT_ARRAY = new ArrayFactory<>() {
-        @Override
-        public int[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid int array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return INT_EMPTY_ARRAY;
-
-                default:
-                    return new int[len];
-            }
+    public static final ArrayFactory<int[]> INT_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid int array length: 
" + len);
+        }
+
+        switch (len) {
+            case 0:
+                return INT_EMPTY_ARRAY;
+
+            default:
+                return new int[len];
         }
     };
 
     /** {@code long} array factory. */
-    public static final ArrayFactory<long[]> LONG_ARRAY = new ArrayFactory<>() 
{
-        @Override
-        public long[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid long array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return LONG_EMPTY_ARRAY;
-
-                default:
-                    return new long[len];
-            }
+    public static final ArrayFactory<long[]> LONG_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid long array length: 
" + len);
+        }
+
+        switch (len) {
+            case 0:
+                return LONG_EMPTY_ARRAY;
+
+            default:
+                return new long[len];
         }
     };
 
     /** {@code float} array factory. */
-    public static final ArrayFactory<float[]> FLOAT_ARRAY = new 
ArrayFactory<>() {
-        @Override
-        public float[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid float array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return FLOAT_EMPTY_ARRAY;
-
-                default:
-                    return new float[len];
-            }
+    public static final ArrayFactory<float[]> FLOAT_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid float array 
length: " + len);
+        }
+
+        switch (len) {
+            case 0:
+                return FLOAT_EMPTY_ARRAY;
+
+            default:
+                return new float[len];
         }
     };
 
     /** {@code double} array factory. */
-    public static final ArrayFactory<double[]> DOUBLE_ARRAY = new 
ArrayFactory<>() {
-        @Override
-        public double[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid double array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return DOUBLE_EMPTY_ARRAY;
-
-                default:
-                    return new double[len];
-            }
+    public static final ArrayFactory<double[]> DOUBLE_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid double array 
length: " + len);
+        }
+
+        switch (len) {
+            case 0:
+                return DOUBLE_EMPTY_ARRAY;
+
+            default:
+                return new double[len];
         }
     };
 
     /** {@code char} array factory. */
-    public static final ArrayFactory<char[]> CHAR_ARRAY = new ArrayFactory<>() 
{
-        @Override
-        public char[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid char array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return CHAR_EMPTY_ARRAY;
-
-                default:
-                    return new char[len];
-            }
+    public static final ArrayFactory<char[]> CHAR_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid char array length: 
" + len);
+        }
+
+        switch (len) {
+            case 0:
+                return CHAR_EMPTY_ARRAY;
+
+            default:
+                return new char[len];
         }
     };
 
     /** {@code boolean} array factory. */
-    public static final ArrayFactory<boolean[]> BOOLEAN_ARRAY = new 
ArrayFactory<>() {
-        @Override
-        public boolean[] of(int len) {
-            if (len < 0) {
-                throw new IgniteInternalException("Read invalid boolean array 
length: " + len);
-            }
-
-            switch (len) {
-                case 0:
-                    return BOOLEAN_EMPTY_ARRAY;
-
-                default:
-                    return new boolean[len];
-            }
+    public static final ArrayFactory<boolean[]> BOOLEAN_ARRAY = len -> {
+        if (len < 0) {
+            throw new IgniteInternalException("Read invalid boolean array 
length: " + len);
+        }
+
+        switch (len) {
+            case 0:
+                return BOOLEAN_EMPTY_ARRAY;
+
+            default:
+                return new boolean[len];
         }
     };
 
+    /**
+     * Stub.
+     */
+    private ArrayUtils() {
+        // No op.
+    }
+
     /**
      * Returns {@code true} if {@code null} or an empty array is provided, 
{@code false} otherwise.
      *
      * @param arr Array to check.
      * @param <T> Array element type.
-     * @return {@code true} if {@code null} or an empty array is provided, 
{@code false} otherwise.

Review comment:
       Returned back.




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