Throw an exception if the object is a NaN or infinite number. @param o The object to test. If not Float or Double, accepted without exceptions. @throws RuntimeException If o is infinite or NaN.
(Object o)
| 1530 | * @throws RuntimeException If o is infinite or NaN. |
| 1531 | */ |
| 1532 | static protected void testValidity(Object o) { |
| 1533 | if (o != null) { |
| 1534 | if (o instanceof Double) { |
| 1535 | if (((Double)o).isInfinite() || ((Double)o).isNaN()) { |
| 1536 | throw new RuntimeException( |
| 1537 | "JSON does not allow non-finite numbers."); |
| 1538 | } |
| 1539 | } else if (o instanceof Float) { |
| 1540 | if (((Float)o).isInfinite() || ((Float)o).isNaN()) { |
| 1541 | throw new RuntimeException( |
| 1542 | "JSON does not allow non-finite numbers."); |
| 1543 | } |
| 1544 | } |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | |
| 1549 | // /** |
no outgoing calls
no test coverage detected