Account: Use Guava for Id#tryParse
This was hand-rolled when this needed to compile under GWT; no longer.
Change-Id: I40233232b966d31850558108b3981e5f2dcf0821
diff --git a/java/com/google/gerrit/reviewdb/client/Account.java b/java/com/google/gerrit/reviewdb/client/Account.java
index d98474b..47c9b40 100644
--- a/java/com/google/gerrit/reviewdb/client/Account.java
+++ b/java/com/google/gerrit/reviewdb/client/Account.java
@@ -18,6 +18,7 @@
import static com.google.gerrit.reviewdb.client.RefNames.REFS_STARRED_CHANGES;
import static com.google.gerrit.reviewdb.client.RefNames.REFS_USERS;
+import com.google.common.primitives.Ints;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gwtorm.client.IntKey;
import java.sql.Timestamp;
@@ -69,11 +70,7 @@
/** Parse an Account.Id out of a string representation. */
public static Optional<Id> tryParse(String str) {
- try {
- return Optional.of(new Id(Integer.parseInt(str)));
- } catch (NumberFormatException e) {
- return Optional.empty();
- }
+ return Optional.ofNullable(Ints.tryParse(str)).map(Id::new);
}
public static Id fromRef(String name) {