public static Serializable fromBytes()

in modules/configuration/src/main/java/org/apache/ignite/internal/configuration/util/ConfigurationSerializationUtil.java [250:384]


    public static Serializable fromBytes(byte[] bytes) {
        ByteBuffer buf = ByteBuffer.wrap(bytes);

        buf.order(ByteOrder.LITTLE_ENDIAN);

        byte header = buf.get();

        switch (header) {
            case BOOLEAN:
                return ByteUtils.byteToBoolean(buf.get());

            case BYTE:
                return buf.get();

            case SHORT:
                return buf.getShort();

            case INT:
                return buf.getInt();

            case LONG:
                return buf.getLong();

            case CHAR:
                return buf.getChar();

            case FLOAT:
                return buf.getFloat();

            case DOUBLE:
                return buf.getDouble();

            case STRING:
                return new String(bytes, 1, bytes.length - 1, StandardCharsets.UTF_8);

            case UUID:
                return new UUID(buf.getLong(), buf.getLong());

            case BOOLEAN | ARRAY: {
                return decompressBooleanArray(bytes);
            }

            case BYTE | ARRAY:
                return Arrays.copyOfRange(bytes, 1, bytes.length);

            case SHORT | ARRAY: {
                short[] shorts = new short[bytes.length / Short.BYTES];

                for (int i = 0; i < shorts.length; i++) {
                    shorts[i] = buf.getShort();
                }

                return shorts;
            }

            case INT | ARRAY: {
                int[] ints = new int[bytes.length / Integer.BYTES];

                for (int i = 0; i < ints.length; i++) {
                    ints[i] = buf.getInt();
                }

                return ints;
            }

            case LONG | ARRAY: {
                long[] longs = new long[bytes.length / Long.BYTES];

                for (int i = 0; i < longs.length; i++) {
                    longs[i] = buf.getLong();
                }

                return longs;
            }

            case CHAR | ARRAY: {
                char[] chars = new char[bytes.length / Character.BYTES];

                for (int i = 0; i < chars.length; i++) {
                    chars[i] = buf.getChar();
                }

                return chars;
            }

            case FLOAT | ARRAY: {
                float[] floats = new float[bytes.length / Float.BYTES];

                for (int i = 0; i < floats.length; i++) {
                    floats[i] = buf.getFloat();
                }

                return floats;
            }

            case DOUBLE | ARRAY: {
                double[] doubles = new double[bytes.length / Double.BYTES];

                for (int i = 0; i < doubles.length; i++) {
                    doubles[i] = buf.getDouble();
                }

                return doubles;
            }

            case STRING | ARRAY: {
                List<String> res = new ArrayList<>();

                int offset = 1;

                while (offset != bytes.length) {
                    int size = buf.getInt(offset);

                    res.add(new String(bytes, offset + Integer.BYTES, size, StandardCharsets.UTF_8));

                    offset += Integer.BYTES + size;
                }

                return res.toArray(EMPTY_STRING_ARRAY);
            }

            case UUID | ARRAY: {
                UUID[] uuids = new UUID[bytes.length / (Long.BYTES * 2)];

                for (int i = 0; i < uuids.length; i++) {
                    uuids[i] = new UUID(buf.getLong(), buf.getLong());
                }

                return uuids;
            }

            default:
                throw new IllegalArgumentException(Arrays.toString(bytes));
        }
    }