Class RomanNumeralConverter

java.lang.Object
johnsmith.enchantmentcore.api.util.RomanNumeralConverter

public final class RomanNumeralConverter extends Object
Utility class for converting between standard integers and classical Roman numeral strings in the range $[1, 3999]$.
  • Method Details

    • toRoman

      public static String toRoman(int number)
      Converts an integer into its classical Roman numeral representation.

      Supports integers in the closed interval $[1, 3999]$. Values outside this range are returned as standard base-10 Arabic numeral strings via String.valueOf(int).

      Parameters:
      number - The integer to convert.
      Returns:
      The Roman numeral string, or the Arabic numeral string if number < 1 or number > 3999.
    • parse

      public static int parse(String romanNumeral)
      Parses a Roman numeral string into its integer value.

      Supports numerals in the classical range from "I" ($1$) to "MMMCMXCIX" ($3999$).

      Parameters:
      romanNumeral - The Roman numeral string to parse (case-insensitive).
      Returns:
      The parsed integer value in $[1, 3999]$, or -1 if the value is null, blank, or malformed.