public BigDecimalAssert asNumber ( ) { isPresent ( NUMBER . getDescription ( ) ) ; Node node = getNode ( actual , "" ) ; if ( node . getNodeType ( ) == NUMBER ) { return createBigDecimalAssert ( node . decimalValue ( ) ) ; } else if ( node . getNodeType ( ) == STRING ) { try { return createBigDecimalAssert ( new BigDecimal ( node . asText ( ) ) ) ; } catch ( NumberFormatException e ) { failWithMessage ( "Node \"" + path + "\" can not be converted to number expected: <a number> but was: <" + quoteTextValue ( node . getValue ( ) ) + ">." ) ; } } else { failOnType ( node , "number or string" ) ; } return null ; }
Asserts that given node is present and is of type number or a string that can be parsed as a number .