package com.amalgam.lang;

import android.util.Log;

/**
 * @author KeishinYokomaku
 */
@SuppressWarnings("unused") // public APIs
public final class NumberUtils {
	public static final String TAG = NumberUtils.class.getSimpleName();

	private NumberUtils() {
		throw new AssertionError();
	}

	public static Long tryParseLong(String number) {
		try {
			return Long.parseLong(number);
		} catch (NumberFormatException e) {
			Log.i(TAG, "cannot convert the string to the number");
			return null;
		}
	}

	public static Integer tryParseInt(String number) {
		try {
			return Integer.parseInt(number);
		} catch (NumberFormatException e) {
			Log.i(TAG, "cannot convert the string to the number");
			return null;
		}
	}

	public static Float tryParseFloat(String number) {
		try {
			return Float.parseFloat(number);
		} catch (NumberFormatException e) {
			Log.i(TAG, "cannot convert the string to the number");
			return null;
		}
	}

	public static Double tryParseDouble(String number) {
		try {
			return Double.parseDouble(number);
		} catch (NumberFormatException e) {
			Log.i(TAG, "cannot convert the string to the number");
			return null;
		}
	}

	public static boolean isNumber(String number) {
		return tryParseInt(number) != null || tryParseLong(number) != null ||
				tryParseFloat(number) != null || tryParseDouble(number) != null;
	}
}
@@ -332,32 +332,136 @@
 g number) %7B%0A
+%09%09return tryParseLong(number, 0L);%0A%09%7D%0A%0A%09public static Long tryParseLong(String number, Long fallback) %7B%0A
 %09%09try %7B%0A
 %09%09%09return Lo
@@ -440,32 +440,32 @@
 back) %7B%0A%09%09try %7B%0A
-
 %09%09%09return Long.p
@@ -580,36 +580,40 @@
 er%22);%0A%09%09%09return 
-null
+fallback
 ;%0A%09%09%7D%0A%09%7D%0A%0A%09publi
@@ -650,32 +650,139 @@
 tring number) %7B%0A
+%09%09return tryParseInt(number, 0);%0A%09%7D%0A%0A%09public static Integer tryParseInt(String number, Integer fallback) %7B%0A
 %09%09try %7B%0A%09%09%09retur
@@ -907,36 +907,40 @@
 er%22);%0A%09%09%09return 
-null
+fallback
 ;%0A%09%09%7D%0A%09%7D%0A%0A%09publi
@@ -977,32 +977,141 @@
 tring number) %7B%0A
+%09%09return tryParseFloat(number, 0.f);%0A%09%7D%0A%0A%09public static Float tryParseFloat(String number, Float fallback) %7B%0A
 %09%09try %7B%0A%09%09%09retur
@@ -1236,36 +1236,40 @@
 er%22);%0A%09%09%09return 
-null
+fallback
 ;%0A%09%09%7D%0A%09%7D%0A%0A%09publi
@@ -1312,24 +1312,137 @@
 g number) %7B%0A
+%09%09return tryParseDouble(number, 0.d);%0A%09%7D%0A%0A%09public static Double tryParseDouble(String number, Double fallback) %7B%0A
 %09%09try %7B%0A%09%09%09r
@@ -1581,20 +1581,24 @@
 %09return 
-null
+fallback
 ;%0A%09%09%7D%0A%09%7D
@@ -1667,32 +1667,38 @@
 yParseInt(number
+, null
 ) != null %7C%7C try
@@ -1709,24 +1709,30 @@
 eLong(number
+, null
 ) != null %7C%7C
@@ -1752,24 +1752,30 @@
 Float(number
+, null
 ) != null %7C%7C
@@ -1796,16 +1796,22 @@
 e(number
+, null
 ) != nul

Add fallback API for number utils