/**
   * Constructs a new {@code MathContext} from a string. The string has to specify the precision and
   * the rounding mode to be used and has to follow the following syntax:
   * "precision=<precision> roundingMode=<roundingMode>" This is the same form as the
   * one returned by the {@link #toString} method.
   *
   * @throws IllegalArgumentException if the string is not in the correct format or if the precision
   *     specified is < 0.
   */
  @DSComment("From safe class list")
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2013-12-30 12:56:34.348 -0500",
      hash_original_method = "1D8B76B7C700FBF158167DD4C05A3C30",
      hash_generated_method = "96CB7A0DB097A7BF33DE16B65A96E3E8")
  public MathContext(String s) {
    int precisionLength = "precision=".length();
    int roundingModeLength = "roundingMode=".length();

    int spaceIndex;
    if (!s.startsWith("precision=") || (spaceIndex = s.indexOf(' ', precisionLength)) == -1) {
      throw invalidMathContext("Missing precision", s);
    }
    String precisionString = s.substring(precisionLength, spaceIndex);
    try {
      this.precision = Integer.parseInt(precisionString);
    } catch (NumberFormatException nfe) {
      throw invalidMathContext("Bad precision", s);
    }

    int roundingModeStart = spaceIndex + 1;
    if (!s.regionMatches(roundingModeStart, "roundingMode=", 0, roundingModeLength)) {
      throw invalidMathContext("Missing rounding mode", s);
    }
    roundingModeStart += roundingModeLength;
    this.roundingMode = RoundingMode.valueOf(s.substring(roundingModeStart));

    checkValid();
  }
 /**
  * Returns the hash code for this {@code MathContext} instance.
  *
  * @return the hash code for this {@code MathContext}.
  */
 @DSComment("From safe class list")
 @DSSafe(DSCat.SAFE_LIST)
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:56:34.364 -0500",
     hash_original_method = "CDDF05FC589C0F0146B62DD26D215A30",
     hash_generated_method = "B195C6308746B1DAC1EA450308C3E284")
 @Override
 public int hashCode() {
   // Make place for the necessary bits to represent 8 rounding modes
   return ((precision << 3) | roundingMode.ordinal());
 }