1 package net.pterodactylus.sone.utils;
3 import javax.annotation.Nonnull;
4 import javax.annotation.Nullable;
6 import com.google.common.primitives.Ints;
7 import com.google.common.primitives.Longs;
10 * Parses numbers from strings.
12 public class NumberParsers {
15 public static Integer parseInt(@Nullable String text,
16 @Nullable Integer defaultValue) {
20 Integer value = Ints.tryParse(text);
21 return (value == null) ? defaultValue : value;
25 public static Long parseLong(@Nullable String text,
26 @Nullable Long defaultValue) {
30 Long value = Longs.tryParse(text);
31 return (value == null) ? defaultValue : value;