class SizeFormat {

    public static long parseAsByteCount(String bytesWithUnit) {
        UnitParser.ParsingResult parsingResult = UnitParser.parse(bytesWithUnit);
        Unit unit = parsingResult.getUnit()
            .map(rawValue -> Unit.of(rawValue)
                .orElseThrow(() -> new IllegalArgumentException("Unknown unit " + rawValue)))
            .orElse(Unit.Byte);

        return unit.toByteCount(parsingResult.getNumber());
    }

}