public static Number asNumber(String value,Supplier<Number> defaultValueProvider){
  if (value != null) {
    try {
      return Short.valueOf(value);
    }
 catch (    NumberFormatException e1) {
      try {
        return Integer.valueOf(value);
      }
 catch (      NumberFormatException e2) {
        try {
          return Long.valueOf(value);
        }
 catch (        NumberFormatException e3) {
          try {
            return Float.valueOf(value);
          }
 catch (          NumberFormatException e4) {
            try {
              return Double.valueOf(value);
            }
 catch (            NumberFormatException e5) {
              try {
                return new BigInteger(value);
              }
 catch (              NumberFormatException e6) {
                try {
                  return new BigDecimal(value);
                }
 catch (                NumberFormatException e7) {
                }
              }
            }
          }
        }
      }
    }
  }
  return defaultValueProvider != null ? defaultValueProvider.get() : null;
}

public static Number asNumber ( String value , Supplier < Number > defaultValueProvider ) { if ( value != null ) { try { return Short . valueOf ( value ) ; } catch ( NumberFormatException e1 ) { try { return Integer . valueOf ( value ) ; } catch ( NumberFormatException e2 ) { try { return Long . valueOf ( value ) ; } catch ( NumberFormatException e3 ) { try { return Float . valueOf ( value ) ; } catch ( NumberFormatException e4 ) { try { return Double . valueOf ( value ) ; } catch ( NumberFormatException e5 ) { try { return new BigInteger ( value ) ; } catch ( NumberFormatException e6 ) { try { return new BigDecimal ( value ) ; } catch ( NumberFormatException e7 ) { } } } } } } } } return defaultValueProvider != null ? defaultValueProvider . get ( ) : null ; }
parse the supplied string as a number .
