### Question:
NumberUtil { public static Optional<Integer> toInt(String text) { try { return Optional.of(NumberUtils.parseNumber(text, Integer.class)); } catch (IllegalArgumentException e) { logger.error("无法将 ‘" + text + "’ 转换为数字", e); return Optional.empty(); } }  static Optional<Integer> toInt(String text);  }### Answer:
@Test public void to_int() { assertThat(NumberUtil.toInt("1").get()).isEqualTo(1); assertThat(NumberUtil.toInt("a")).isEmpty(); }