private static Result resultFromString(String s) { Result result = Result.fromString(s); // fromString returns FAILURE for unknown strings instead of // IllegalArgumentException. Don't know why the author thought that this // is useful ... if (!result.toString().equals(s)) { throw new IllegalArgumentException("Unknown result type '" + s + "'"); } return result; }