AccountQueryBuilder: Don't use regex to match account ID

Instead just check with Ints.tryParse(...) if it is an integer and
thus a (potential) account ID.

Change-Id: I50fc579a174a80d0c16d1cd0c2782372eab095a9
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-06-30 08:04:17 +02:00
parent 42167fdd13
commit c1eb296f6c

View File

@@ -86,8 +86,9 @@ public class AccountQueryBuilder extends QueryBuilder<AccountState> {
if ("self".equalsIgnoreCase(query)) {
return new AccountIdPredicate(self());
}
if (query.matches("^[1-9][0-9]*$")) {
return new AccountIdPredicate(Account.Id.parse(query));
Integer id = Ints.tryParse(query);
if (id != null) {
return new AccountIdPredicate(new Account.Id(id));
}
throw error("User " + query + " not found");
}