by fanxu123
| 4 | * by fanxu123 |
| 5 | */ |
| 6 | public class HttpUtils { |
| 7 | |
| 8 | public static boolean isEmpty(String value) { |
| 9 | return value == null || "".equals(value); |
| 10 | } |
| 11 | /** |
| 12 | * Convert String to long |
| 13 | * @param value |
| 14 | * @param def default value |
| 15 | * @return |
| 16 | */ |
| 17 | public static long toLong(String value, long def) { |
| 18 | if (isEmpty(value)) { |
| 19 | return def; |
| 20 | } |
| 21 | |
| 22 | try { |
| 23 | return Long.valueOf(value); |
| 24 | } catch (NumberFormatException e) { |
| 25 | e.printStackTrace(); |
| 26 | return def; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Convert String to int |
| 32 | * @param value |
| 33 | * @param def default value |
| 34 | * @return |
| 35 | */ |
| 36 | public static int toInt(String value, int def) { |
| 37 | if (isEmpty(value)) { |
| 38 | return def; |
| 39 | } |
| 40 | try { |
| 41 | return Integer.valueOf(value); |
| 42 | } catch (NumberFormatException e) { |
| 43 | e.printStackTrace(); |
| 44 | return def; |
| 45 | } |
| 46 | } |
| 47 | } |
nothing calls this directly
no outgoing calls
no test coverage detected