public static long parseBytes(String text) throws IllegalArgumentException {
        Objects.requireNonNull(text, "text cannot be null");

        final String trimmed = text.trim();
        if (trimmed.isEmpty()) {
            throw new IllegalArgumentException("argument is an empty- or whitespace-only string");
        }

        final int len = trimmed.length();
        int pos = 0;

        char current;
        while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
            pos++;
        }

        final String number = trimmed.substring(0, pos);
        final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);

        if (number.isEmpty()) {
            throw new NumberFormatException("text does not start with a number");
        }

        final long value;
        try {
            value = Long.parseLong(number); // this throws a NumberFormatException on overflow
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(
                    "The value '"
                            + number
                            + "' cannot be re represented as 64bit number (numeric overflow).");
        }

        final long multiplier = parseUnit(unit).map(MemoryUnit::getMultiplier).orElse(1L);
        final long result = value * multiplier;

        // check for overflow
        if (result / multiplier != value) {
            throw new IllegalArgumentException(
                    "The value '"
                            + text
                            + "' cannot be re represented as 64bit number of bytes (numeric overflow).");
        }

        return result;
    }
@Test
    void testParseBytes() {
        assertThat(MemorySize.parseBytes("1234")).isEqualTo(1234);
        assertThat(MemorySize.parseBytes("1234b")).isEqualTo(1234);
        assertThat(MemorySize.parseBytes("1234 b")).isEqualTo(1234);
        assertThat(MemorySize.parseBytes("1234bytes")).isEqualTo(1234);
        assertThat(MemorySize.parseBytes("1234 bytes")).isEqualTo(1234);
    }