Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time. google-java-format is Google's standard formatter and is somewhat inspired by gofmt[1]. This commit formats everything using google-java-format version 1.2. The downside of this one-off formatting is breaking blame. This can be somewhat hacked around with a tool like git-hyper-blame[2], but it's definitely not optimal until/unless this kind of feature makes its way to git core. Not in this change: * Tool support, e.g. Eclipse. The command must be run manually [3]. * Documentation of best practice, e.g. new 100-column default. [1] https://talks.golang.org/2015/gofmt-en.slide#3 [2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html [3] git ls-files | grep java$ | xargs google-java-format -i Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3 Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:

committed by
David Pursehouse

parent
6723b6d0fa
commit
292fa154c1
@@ -23,7 +23,6 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -39,7 +38,8 @@ public class AccountResolver {
|
||||
private final Provider<InternalAccountQuery> accountQueryProvider;
|
||||
|
||||
@Inject
|
||||
AccountResolver(Realm realm,
|
||||
AccountResolver(
|
||||
Realm realm,
|
||||
AccountByEmailCache byEmail,
|
||||
AccountCache byId,
|
||||
Provider<InternalAccountQuery> accountQueryProvider) {
|
||||
@@ -52,12 +52,11 @@ public class AccountResolver {
|
||||
/**
|
||||
* Locate exactly one account matching the name or name/email string.
|
||||
*
|
||||
* @param nameOrEmail a string of the format
|
||||
* "Full Name <email@example>", just the email address
|
||||
* ("email@example"), a full name ("Full Name"), an account id
|
||||
* ("18419") or an user name ("username").
|
||||
* @return the single account that matches; null if no account matches or
|
||||
* there are multiple candidates.
|
||||
* @param nameOrEmail a string of the format "Full Name <email@example>", just the email
|
||||
* address ("email@example"), a full name ("Full Name"), an account id ("18419") or an user
|
||||
* name ("username").
|
||||
* @return the single account that matches; null if no account matches or there are multiple
|
||||
* candidates.
|
||||
*/
|
||||
public Account find(ReviewDb db, String nameOrEmail) throws OrmException {
|
||||
Set<Account.Id> r = findAll(db, nameOrEmail);
|
||||
@@ -83,14 +82,12 @@ public class AccountResolver {
|
||||
* Find all accounts matching the name or name/email string.
|
||||
*
|
||||
* @param db open database handle.
|
||||
* @param nameOrEmail a string of the format
|
||||
* "Full Name <email@example>", just the email address
|
||||
* ("email@example"), a full name ("Full Name"), an account id
|
||||
* ("18419") or an user name ("username").
|
||||
* @return the accounts that match, empty collection if none. Never null.
|
||||
* @param nameOrEmail a string of the format "Full Name <email@example>", just the email
|
||||
* address ("email@example"), a full name ("Full Name"), an account id ("18419") or an user
|
||||
* name ("username").
|
||||
* @return the accounts that match, empty collection if none. Never null.
|
||||
*/
|
||||
public Set<Account.Id> findAll(ReviewDb db, String nameOrEmail)
|
||||
throws OrmException {
|
||||
public Set<Account.Id> findAll(ReviewDb db, String nameOrEmail) throws OrmException {
|
||||
Matcher m = Pattern.compile("^.* \\(([1-9][0-9]*)\\)$").matcher(nameOrEmail);
|
||||
if (m.matches()) {
|
||||
Account.Id id = Account.Id.parse(m.group(1));
|
||||
@@ -126,14 +123,12 @@ public class AccountResolver {
|
||||
* Locate exactly one account matching the name or name/email string.
|
||||
*
|
||||
* @param db open database handle.
|
||||
* @param nameOrEmail a string of the format
|
||||
* "Full Name <email@example>", just the email address
|
||||
* ("email@example"), a full name ("Full Name").
|
||||
* @return the single account that matches; null if no account matches or
|
||||
* there are multiple candidates.
|
||||
* @param nameOrEmail a string of the format "Full Name <email@example>", just the email
|
||||
* address ("email@example"), a full name ("Full Name").
|
||||
* @return the single account that matches; null if no account matches or there are multiple
|
||||
* candidates.
|
||||
*/
|
||||
public Account findByNameOrEmail(ReviewDb db, String nameOrEmail)
|
||||
throws OrmException {
|
||||
public Account findByNameOrEmail(ReviewDb db, String nameOrEmail) throws OrmException {
|
||||
Set<Account.Id> r = findAllByNameOrEmail(db, nameOrEmail);
|
||||
return r.size() == 1 ? byId.get(r.iterator().next()).getAccount() : null;
|
||||
}
|
||||
@@ -142,13 +137,11 @@ public class AccountResolver {
|
||||
* Locate exactly one account matching the name or name/email string.
|
||||
*
|
||||
* @param db open database handle.
|
||||
* @param nameOrEmail a string of the format
|
||||
* "Full Name <email@example>", just the email address
|
||||
* ("email@example"), a full name ("Full Name").
|
||||
* @param nameOrEmail a string of the format "Full Name <email@example>", just the email
|
||||
* address ("email@example"), a full name ("Full Name").
|
||||
* @return the accounts that match, empty collection if none. Never null.
|
||||
*/
|
||||
public Set<Account.Id> findAllByNameOrEmail(ReviewDb db, String nameOrEmail)
|
||||
throws OrmException {
|
||||
public Set<Account.Id> findAllByNameOrEmail(ReviewDb db, String nameOrEmail) throws OrmException {
|
||||
int lt = nameOrEmail.indexOf('<');
|
||||
int gt = nameOrEmail.indexOf('>');
|
||||
if (lt >= 0 && gt > lt && nameOrEmail.contains("@")) {
|
||||
@@ -185,7 +178,10 @@ public class AccountResolver {
|
||||
|
||||
// At this point we have no clue. Just perform a whole bunch of suggestions
|
||||
// and pray we come up with a reasonable result list.
|
||||
return accountQueryProvider.get().byDefault(nameOrEmail).stream()
|
||||
return accountQueryProvider
|
||||
.get()
|
||||
.byDefault(nameOrEmail)
|
||||
.stream()
|
||||
.map(a -> a.getAccount().getId())
|
||||
.collect(toSet());
|
||||
}
|
||||
|
Reference in New Issue
Block a user