code: private static Object toExternalNumber( Object value)
      {
      Class<?> valueType =
        value == null
        ? null
        : value.getClass();
  
      return
        !(valueType != null && Number.class.isAssignableFrom( valueType))?
        null :
  
        valueType.equals( BigDecimal.class)?
        toExternalNumber( (BigDecimal) value) :
  
        valueType.equals( Long.class)?
        toExternalNumber( new BigDecimal( (Long) value)) :
  
        value;      
      }
docs: If the given value is a number, returns an object equal to its external form.
  Otherwise, returns null.