public static ByteSize parseByteSize(String size) {
        if (size == null) {
            throw new NullPointerException("size is null");
        }
        if (size.isEmpty()) {
            throw new IllegalArgumentException("size is empty");
        }

        Matcher matcher = PATTERN.matcher(size);
        if (!matcher.matches()) {
            throw new IllegalArgumentException("Invalid byte size string '" + size + "'");
        }

        double value = Double.parseDouble(matcher.group(1));  // NumberFormatException extends IllegalArgumentException.

        String unitString = matcher.group(2);
        if (unitString.isEmpty()) {
            return new ByteSize(value, Unit.BYTES);
        } else {
            String upperUnitString = unitString.toUpperCase(Locale.ENGLISH);
            for (Unit unit : Unit.values()) {
                if (unit.getUnitString().toUpperCase(Locale.ENGLISH).equals(upperUnitString)) {
                    return new ByteSize(value, unit);
                }
            }
        }

        throw new IllegalArgumentException("Unknown unit '" + unitString + "'");
    }
Parses and formats byte size representations, such as "4MB", "83GB".

<p>This class is deprecated, to be removed in plan. Any plugin should not use it.
embulk-core/src/main/java/org/embulk/spi/unit/ByteSize.java