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)
| 1584 | * @throws RuntimeException If o is infinite or NaN. |
| 1585 | */ |
| 1586 | static protected void testValidity(Object o) { |
| 1587 | if (o != null) { |
| 1588 | if (o instanceof Double) { |
| 1589 | if (((Double)o).isInfinite() || ((Double)o).isNaN()) { |
| 1590 | throw new RuntimeException( |
| 1591 | "JSON does not allow non-finite numbers."); |
| 1592 | } |
| 1593 | } else if (o instanceof Float) { |
| 1594 | if (((Float)o).isInfinite() || ((Float)o).isNaN()) { |
| 1595 | throw new RuntimeException( |
| 1596 | "JSON does not allow non-finite numbers."); |
| 1597 | } |
| 1598 | } |
| 1599 | } |
| 1600 | } |
| 1601 | |
| 1602 | |
| 1603 | // /** |
no outgoing calls
no test coverage detected