Remove @author tags
[Sone.git] / src / main / java / net / pterodactylus / sone / utils / NumberParsers.java
1 package net.pterodactylus.sone.utils;
2
3 import javax.annotation.Nonnull;
4 import javax.annotation.Nullable;
5
6 import com.google.common.primitives.Ints;
7 import com.google.common.primitives.Longs;
8
9 /**
10  * Parses numbers from strings.
11  */
12 public class NumberParsers {
13
14         @Nullable
15         public static Integer parseInt(@Nullable String text,
16                         @Nullable Integer defaultValue) {
17                 if (text == null) {
18                         return defaultValue;
19                 }
20                 Integer value = Ints.tryParse(text);
21                 return (value == null) ? defaultValue : value;
22         }
23
24         @Nullable
25         public static Long parseLong(@Nullable String text,
26                         @Nullable Long defaultValue) {
27                 if (text == null) {
28                         return defaultValue;
29                 }
30                 Long value = Longs.tryParse(text);
31                 return (value == null) ? defaultValue : value;
32         }
33
34 }