withUnit static method

String withUnit(
  1. String moneyTxt,
  2. MoneyUnit unit
)

with unit. 拼接单位.

Exhaustive switch expression over MoneyUnit — adding a new enum value will produce a compile-time error here instead of silently falling through.

Implementation

static String withUnit(String moneyTxt, MoneyUnit unit) {
  return switch (unit) {
    MoneyUnit.NORMAL => moneyTxt,
    MoneyUnit.YUAN => YUAN + moneyTxt,
    MoneyUnit.YUAN_ZH => moneyTxt + YUAN_ZH,
    MoneyUnit.DOLLAR => DOLLAR + moneyTxt,
  };
}