class Quantity implements Comparable<Quantity> {

  @Nullable
  public static Quantity parse(@NotNull String value) {
    Matcher matcher = QUANTITY_PATTERN.matcher(value);
    if (!matcher.matches()) {
      return null;
    }
    try {
      return new Quantity(Integer.parseInt(matcher.group(1)), matcher.group(3).trim());
    }
    catch (NumberFormatException ignore) {
      return null;  // Format this value as if this was not a value with a unit
    }
  }

  private  Quantity(int value, @NotNull String unit);

}