Fix deprecation warnings caused by Guava upgrade

Replace Objects.firstNonNull() with MoreObjects.firstNonNull().

Change-Id: I657a532562ca598aca4130f4e55fdfde72fa4434
This commit is contained in:
David Ostrovsky 2014-09-08 16:15:33 +02:00 committed by David Pursehouse
parent 7d76f7d348
commit ac332d22f5
56 changed files with 135 additions and 118 deletions

View File

@ -16,7 +16,7 @@ package com.google.gerrit.httpd;
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.server.AccessPath;
@ -183,7 +183,7 @@ class ProjectBasicAuthFilter implements Filter {
}
private String encoding(HttpServletRequest req) {
return Objects.firstNonNull(req.getCharacterEncoding(), "UTF-8");
return MoreObjects.firstNonNull(req.getCharacterEncoding(), "UTF-8");
}
class Response extends HttpServletResponseWrapper {

View File

@ -16,7 +16,7 @@ package com.google.gerrit.httpd.auth.become;
import static com.google.gerrit.reviewdb.client.AccountExternalId.SCHEME_USERNAME;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.extensions.registration.DynamicItem;
@ -122,7 +122,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
if (res != null) {
webSession.get().login(res, false);
final StringBuilder rdr = new StringBuilder();
rdr.append(Objects.firstNonNull(
rdr.append(MoreObjects.firstNonNull(
Strings.emptyToNull(req.getContextPath()),
"/"));
if (IS_DEV && req.getParameter("gwt.codesvr") != null) {

View File

@ -14,7 +14,7 @@
package com.google.gerrit.httpd.auth.container;
import static com.google.common.base.Objects.firstNonNull;
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.net.HttpHeaders.AUTHORIZATION;
import static com.google.gerrit.reviewdb.client.AccountExternalId.SCHEME_GERRIT;

View File

@ -14,7 +14,7 @@
package com.google.gerrit.httpd.auth.ldap;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.registration.DynamicItem;
@ -72,7 +72,7 @@ class LdapLoginServlet extends HttpServlet {
private void sendForm(HttpServletRequest req, HttpServletResponse res,
@Nullable String errorMessage) throws IOException {
String self = req.getRequestURI();
String cancel = Objects.firstNonNull(urlProvider.get(req), "/");
String cancel = MoreObjects.firstNonNull(urlProvider.get(req), "/");
cancel += LoginUrlToken.getToken(req);
Document doc = headers.parse(LdapLoginServlet.class, "LoginForm.html");

View File

@ -32,7 +32,7 @@ import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMultimap;
@ -353,12 +353,12 @@ public class RestApiServlet extends HttpServlet {
replyError(req, res, status = SC_CONFLICT, e.getMessage(), e.caching());
} catch (PreconditionFailedException e) {
replyError(req, res, status = SC_PRECONDITION_FAILED,
Objects.firstNonNull(e.getMessage(), "Precondition failed"), e.caching());
MoreObjects.firstNonNull(e.getMessage(), "Precondition failed"), e.caching());
} catch (ResourceNotFoundException e) {
replyError(req, res, status = SC_NOT_FOUND, "Not found", e.caching());
} catch (UnprocessableEntityException e) {
replyError(req, res, status = 422,
Objects.firstNonNull(e.getMessage(), "Unprocessable Entity"), e.caching());
MoreObjects.firstNonNull(e.getMessage(), "Unprocessable Entity"), e.caching());
} catch (AmbiguousViewException e) {
replyError(req, res, status = SC_NOT_FOUND, e.getMessage());
} catch (MalformedJsonException e) {

View File

@ -16,7 +16,7 @@ package com.google.gerrit.httpd.rpc.project;
import static com.google.gerrit.common.ProjectAccessUtil.mergeSections;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.data.Permission;
@ -139,7 +139,7 @@ public abstract class ProjectAccessHandler<T> extends Handler<T> {
parentProjectUpdate = true;
try {
setParent.get().validateParentUpdate(projectControl,
Objects.firstNonNull(parentProjectName, allProjects.get()).get(),
MoreObjects.firstNonNull(parentProjectName, allProjects.get()).get(),
checkIfOwner);
} catch (AuthException e) {
throw new UpdateParentFailedException(

View File

@ -14,7 +14,7 @@
package com.google.gerrit.httpd.auth.openid;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -220,7 +220,8 @@ class LoginForm extends HttpServlet {
private void sendForm(HttpServletRequest req, HttpServletResponse res,
boolean link, @Nullable String errorMessage) throws IOException {
String self = req.getRequestURI();
String cancel = Objects.firstNonNull(urlProvider != null ? urlProvider.get() : "/", "/");
String cancel = MoreObjects.firstNonNull(
urlProvider != null ? urlProvider.get() : "/", "/");
cancel += LoginUrlToken.getToken(req);
Document doc = header.parse(LoginForm.class, "LoginForm.html");

View File

@ -17,7 +17,7 @@ package com.google.gerrit.pgm;
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.common.ChangeHookRunner;
import com.google.gerrit.httpd.AllRequestFilter;
import com.google.gerrit.httpd.GerritUiOptions;
@ -283,7 +283,7 @@ public class Daemon extends SiteProgram {
initSshd();
}
if (Objects.firstNonNull(httpd, true)) {
if (MoreObjects.firstNonNull(httpd, true)) {
initHttpd();
}
@ -327,7 +327,7 @@ public class Daemon extends SiteProgram {
modules.add(new PluginRestApiModule());
modules.add(new RestCacheAdminModule());
modules.add(createIndexModule());
if (Objects.firstNonNull(httpd, true)) {
if (MoreObjects.firstNonNull(httpd, true)) {
modules.add(new CanonicalWebUrlModule() {
@Override
protected Class<? extends Provider<String>> provider() {

View File

@ -18,7 +18,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.google.common.base.Charsets;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.escape.Escaper;
import com.google.common.html.HtmlEscapers;
@ -648,7 +648,7 @@ public class JettyServer {
throws IOException, BuildFailureException {
log.info("buck build " + target);
Properties properties = loadBuckProperties(gen);
String buck = Objects.firstNonNull(properties.getProperty("buck"), "buck");
String buck = MoreObjects.firstNonNull(properties.getProperty("buck"), "buck");
ProcessBuilder proc = new ProcessBuilder(buck, "build", target)
.directory(root)
.redirectErrorStream(true);

View File

@ -14,7 +14,7 @@
package com.google.gerrit.pgm.init;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.pgm.init.api.Section;
import com.google.gerrit.server.config.AllUsersNameProvider;
@ -27,7 +27,7 @@ public class AllUsersNameOnInitProvider implements Provider<String> {
@Inject
AllUsersNameOnInitProvider(Section.Factory sections) {
String n = sections.get("gerrit", null).get("allUsers");
name = Objects.firstNonNull(
name = MoreObjects.firstNonNull(
Strings.emptyToNull(n), AllUsersNameProvider.DEFAULT);
}

View File

@ -17,7 +17,7 @@ package com.google.gerrit.pgm.init;
import static com.google.gerrit.server.schema.DataSourceProvider.Context.SINGLE_USER;
import static com.google.inject.Stage.PRODUCTION;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import com.google.gerrit.common.Die;
import com.google.gerrit.pgm.init.api.ConsoleUI;
@ -191,7 +191,8 @@ public class BaseInit extends SiteProgram {
bind(ConsoleUI.class).toInstance(ui);
bind(File.class).annotatedWith(SitePath.class).toInstance(sitePath);
List<String> plugins =
Objects.firstNonNull(getInstallPlugins(), Lists.<String> newArrayList());
MoreObjects.firstNonNull(
getInstallPlugins(), Lists.<String> newArrayList());
bind(new TypeLiteral<List<String>>() {}).annotatedWith(
InstallPlugins.class).toInstance(plugins);
bind(PluginsDistribution.class).toInstance(pluginsDistribution);

View File

@ -14,7 +14,7 @@
package com.google.gerrit.pgm.init;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitStep;
@ -99,7 +99,8 @@ public class InitPluginStepsLoader {
private Injector getPluginInjector(final File jarFile) throws IOException {
final String pluginName =
Objects.firstNonNull(JarPluginProvider.getJarPluginName(jarFile),
MoreObjects.firstNonNull(
JarPluginProvider.getJarPluginName(jarFile),
PluginLoader.nameOf(jarFile));
return initInjector.createChildInjector(new AbstractModule() {
@Override

View File

@ -14,7 +14,7 @@
package com.google.gerrit.pgm.init.api;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.inject.Inject;
@ -26,7 +26,7 @@ public class AllProjectsNameOnInitProvider implements Provider<String> {
@Inject
AllProjectsNameOnInitProvider(Section.Factory sections) {
String n = sections.get("gerrit", null).get("allProjects");
name = Objects.firstNonNull(
name = MoreObjects.firstNonNull(
Strings.emptyToNull(n), AllProjectsNameProvider.DEFAULT);
}

View File

@ -14,7 +14,7 @@
package com.google.gerrit.audit;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
@ -87,12 +87,12 @@ public class AuditEvent {
Multimap<String, ?> params, Object result) {
Preconditions.checkNotNull(what, "what is a mandatory not null param !");
this.sessionId = Objects.firstNonNull(sessionId, UNKNOWN_SESSION_ID);
this.sessionId = MoreObjects.firstNonNull(sessionId, UNKNOWN_SESSION_ID);
this.who = who;
this.what = what;
this.when = when;
this.timeAtStart = this.when;
this.params = Objects.firstNonNull(params, EMPTY_PARAMS);
this.params = MoreObjects.firstNonNull(params, EMPTY_PARAMS);
this.uuid = new UUID();
this.result = result;
this.elapsed = TimeUtil.nowMs() - timeAtStart;

View File

@ -31,7 +31,7 @@ import static com.google.gerrit.extensions.common.ListChangesOption.REVIEWED;
import static com.google.gerrit.extensions.common.ListChangesOption.WEB_LINKS;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.HashMultimap;
@ -683,7 +683,8 @@ public class ChangeJson {
continue;
}
for (ApprovalInfo ai : label.all) {
if (ctl.canRemoveReviewer(ai._id, Objects.firstNonNull(ai.value, 0))) {
if (ctl.canRemoveReviewer(ai._id,
MoreObjects.firstNonNull(ai.value, 0))) {
removable.add(ai._id);
} else {
fixed.add(ai._id);

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.change;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.gerrit.extensions.restapi.RestResource;
@ -70,7 +70,7 @@ public class ChangeResource implements RestResource, HasETag {
byte[] buf = new byte[20];
for (ProjectState p : control.getProjectControl().getProjectState().tree()) {
ObjectId id = p.getConfig().getRevision();
Objects.firstNonNull(id, ObjectId.zeroId()).copyRawTo(buf, 0);
MoreObjects.firstNonNull(id, ObjectId.zeroId()).copyRawTo(buf, 0);
h.putBytes(buf);
}
return h.hash().toString();

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.change;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.gerrit.common.data.PatchScript;
@ -139,7 +139,8 @@ public class GetDiff implements RestReadView<FileResource> {
Result result = new Result();
if (ps.getDisplayMethodA() != DisplayMethod.NONE) {
result.metaA = new FileMeta();
result.metaA.name = Objects.firstNonNull(ps.getOldName(), ps.getNewName());
result.metaA.name = MoreObjects.firstNonNull(ps.getOldName(),
ps.getNewName());
setContentType(result.metaA, state, ps.getFileModeA(), ps.getMimeTypeA());
result.metaA.lines = ps.getA().size();
}

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.change;
import static com.google.common.base.Objects.firstNonNull;
import static com.google.common.base.MoreObjects.firstNonNull;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

View File

@ -17,7 +17,7 @@ package com.google.gerrit.server.change;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.gerrit.server.PatchLineCommentsUtil.setCommentRevId;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -374,7 +374,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
}
}
switch (Objects.firstNonNull(draftsHandling, DraftHandling.DELETE)) {
switch (MoreObjects.firstNonNull(draftsHandling, DraftHandling.DELETE)) {
case KEEP:
default:
break;

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.change;
import static com.google.gerrit.common.data.SubmitRecord.Status.OK;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
@ -139,10 +139,10 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
this.changes = changes;
this.indexer = indexer;
this.labelNormalizer = labelNormalizer;
this.label = Objects.firstNonNull(
this.label = MoreObjects.firstNonNull(
Strings.emptyToNull(cfg.getString("change", null, "submitLabel")),
"Submit");
this.titlePattern = new ParameterizedString(Objects.firstNonNull(
this.titlePattern = new ParameterizedString(MoreObjects.firstNonNull(
cfg.getString("change", null, "submitTooltip"),
DEFAULT_TOOLTIP));
}

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.change;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@ -287,7 +287,7 @@ public class SuggestReviewers implements RestReadView<ChangeResource> {
private String getSortValue() {
return account != null
? Objects.firstNonNull(account.email,
? MoreObjects.firstNonNull(account.email,
Strings.nullToEmpty(account.name))
: Strings.nullToEmpty(group.name);
}

View File

@ -18,7 +18,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@ -86,7 +86,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
if (input.rule != null && !rules.isProjectRulesEnabled()) {
throw new AuthException("project rules are disabled");
}
input.filters = Objects.firstNonNull(input.filters, filters);
input.filters = MoreObjects.firstNonNull(input.filters, filters);
SubmitRuleEvaluator evaluator = new SubmitRuleEvaluator(
db.get(),

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.change;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
@ -66,7 +66,7 @@ public class TestSubmitType implements RestModifyView<RevisionResource, Input> {
if (input.rule != null && !rules.isProjectRulesEnabled()) {
throw new AuthException("project rules are disabled");
}
input.filters = Objects.firstNonNull(input.filters, filters);
input.filters = MoreObjects.firstNonNull(input.filters, filters);
SubmitRuleEvaluator evaluator = new SubmitRuleEvaluator(
db.get(),

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.config;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.gerrit.server.git.ProjectConfig;
@ -86,7 +86,8 @@ public class PluginConfig {
if (defaultValue == null) {
return cfg.getString(PLUGIN, pluginName, name);
} else {
return Objects.firstNonNull(cfg.getString(PLUGIN, pluginName, name), defaultValue);
return MoreObjects.firstNonNull(cfg.getString(PLUGIN, pluginName, name),
defaultValue);
}
}

View File

@ -17,6 +17,7 @@ package com.google.gerrit.server.git;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@ -98,7 +99,7 @@ public class LabelNormalizer {
@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("unchanged", unchanged)
.add("updated", updated)
.add("deleted", deleted)

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.git;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.reviewdb.client.Project;
@ -142,7 +142,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
}
if (notesMigration.enabled()) {
noteDbPath = site.resolve(Objects.firstNonNull(
noteDbPath = site.resolve(MoreObjects.firstNonNull(
cfg.getString("gerrit", null, "noteDbPath"), "notedb"));
} else {
noteDbPath = null;

View File

@ -19,7 +19,7 @@ import static com.google.gerrit.common.data.Permission.isPermission;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
@ -677,7 +677,7 @@ public class ProjectConfig extends VersionedMetaData {
continue;
}
String functionName = Objects.firstNonNull(
String functionName = MoreObjects.firstNonNull(
rc.getString(LABEL, name, KEY_FUNCTION), "MaxWithBlock");
if (LABEL_FUNCTIONS.contains(functionName)) {
label.setFunctionName(functionName);

View File

@ -14,6 +14,7 @@
package com.google.gerrit.server.git;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import org.eclipse.jgit.dircache.DirCache;
@ -308,8 +309,8 @@ public abstract class VersionedMetaData {
if (Objects.equal(src, expected)) {
return revision;
}
return updateRef(Objects.firstNonNull(expected, ObjectId.zeroId()), src,
getRefName());
return updateRef(MoreObjects.firstNonNull(expected, ObjectId.zeroId()),
src, getRefName());
}
@Override

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.group;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.GroupDescription;
@ -101,7 +101,8 @@ public class CreateGroup implements RestModifyView<TopLevelResource, Input> {
CreateGroupArgs args = new CreateGroupArgs();
args.setGroupName(name);
args.groupDescription = Strings.emptyToNull(input.description);
args.visibleToAll = Objects.firstNonNull(input.visibleToAll, defaultVisibleToAll);
args.visibleToAll = MoreObjects.firstNonNull(input.visibleToAll,
defaultVisibleToAll);
args.ownerGroupId = ownerId;
args.initialMembers = ownerId == null
? Collections.singleton(self.get().getAccountId())

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.group;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -135,7 +135,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
public Object apply(TopLevelResource resource) throws OrmException {
final Map<String, GroupInfo> output = Maps.newTreeMap();
for (GroupInfo info : get()) {
output.put(Objects.firstNonNull(
output.put(MoreObjects.firstNonNull(
info.name,
"Group " + Url.decode(info.id)), info);
info.name = null;

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.index;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@ -136,7 +136,7 @@ public class ChangeField {
@Override
public String get(ChangeData input, FillArgs args)
throws OrmException {
return Objects.firstNonNull(input.change().getTopic(), "");
return MoreObjects.firstNonNull(input.change().getTopic(), "");
}
};

View File

@ -15,7 +15,7 @@
package com.google.gerrit.server.index;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Change;
@ -136,7 +136,7 @@ public class IndexRewriteImpl implements ChangeQueryRewriter {
ChangeIndex index = indexes.getSearchIndex();
in = basicRewrites.rewrite(in);
int limit =
Objects.firstNonNull(ChangeQueryBuilder.getLimit(in), MAX_LIMIT);
MoreObjects.firstNonNull(ChangeQueryBuilder.getLimit(in), MAX_LIMIT);
// Increase the limit rather than skipping, since we don't know how many
// skipped results would have been filtered out by the enclosing AndSource.
limit += start;

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.index;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@ -225,7 +225,7 @@ public class IndexedChangeQuery extends Predicate<ChangeData>
@Override
public String toString() {
return Objects.toStringHelper("index")
return MoreObjects.toStringHelper("index")
.add("p", pred)
.add("limit", limit)
.toString();

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.index;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
@ -123,7 +123,7 @@ public class Schema<T> {
@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.addValue(fields.keySet())
.toString();
}

View File

@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState;
import static com.google.gerrit.server.PatchLineCommentsUtil.setCommentRevId;
import static com.google.gerrit.server.notedb.CommentsInNotesUtil.getCommentPsId;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ComparisonChain;
@ -260,7 +261,7 @@ public class ChangeRebuilder {
@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("psId", psId)
.add("who", who)
.add("when", when)

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.plugins;
import static com.google.gerrit.server.plugins.PluginLoader.asTemp;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
@ -60,7 +60,7 @@ public class JarPluginProvider implements ServerPluginProvider {
@Override
public String getPluginName(File srcFile) {
try {
return Objects.firstNonNull(getJarPluginName(srcFile),
return MoreObjects.firstNonNull(getJarPluginName(srcFile),
PluginLoader.nameOf(srcFile));
} catch (IOException e) {
throw new IllegalArgumentException("Invalid plugin file " + srcFile

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.plugins;
import static com.google.common.base.Objects.firstNonNull;
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.collect.Iterables.transform;
import com.google.common.base.Function;

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.plugins;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap;
@ -72,7 +72,8 @@ public class PluginLoader implements LifecycleListener {
static final Logger log = LoggerFactory.getLogger(PluginLoader.class);
public String getPluginName(File srcFile) throws IOException {
return Objects.firstNonNull(getGerritPluginName(srcFile), nameOf(srcFile));
return MoreObjects.firstNonNull(getGerritPluginName(srcFile),
nameOf(srcFile));
}
private final File pluginsDir;
@ -158,7 +159,7 @@ public class PluginLoader implements LifecycleListener {
String fileName = originalName;
File tmp = asTemp(in, ".next_" + fileName + "_", ".tmp", pluginsDir);
String name = Objects.firstNonNull(getGerritPluginName(tmp),
String name = MoreObjects.firstNonNull(getGerritPluginName(tmp),
nameOf(fileName));
if (!originalName.equals(name)) {
log.warn(String.format("Plugin provides its own name: <%s>,"

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.project;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.gerrit.common.data.GlobalCapability;
@ -114,16 +114,18 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
args.ownerIds = ownerIds;
}
args.contributorAgreements =
Objects.firstNonNull(input.useContributorAgreements,
MoreObjects.firstNonNull(input.useContributorAgreements,
InheritableBoolean.INHERIT);
args.signedOffBy =
Objects.firstNonNull(input.useSignedOffBy, InheritableBoolean.INHERIT);
MoreObjects.firstNonNull(input.useSignedOffBy,
InheritableBoolean.INHERIT);
args.contentMerge =
input.submitType == SubmitType.FAST_FORWARD_ONLY
? InheritableBoolean.FALSE : Objects.firstNonNull(
input.useContentMerge, InheritableBoolean.INHERIT);
? InheritableBoolean.FALSE : MoreObjects.firstNonNull(
input.useContentMerge,
InheritableBoolean.INHERIT);
args.changeIdRequired =
Objects.firstNonNull(input.requireChangeId, InheritableBoolean.INHERIT);
MoreObjects.firstNonNull(input.requireChangeId, InheritableBoolean.INHERIT);
try {
args.maxObjectSizeLimit =
ProjectConfig.validMaxObjectSizeLimit(input.maxObjectSizeLimit);

View File

@ -17,7 +17,7 @@ package com.google.gerrit.server.project;
import static com.google.gerrit.reviewdb.client.RefNames.REFS_DASHBOARDS;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
@ -173,7 +173,7 @@ class DashboardsCollection implements
}
UrlEncoded u = new UrlEncoded("/dashboard/");
u.put("title", Objects.firstNonNull(info.title, info.path));
u.put("title", MoreObjects.firstNonNull(info.title, info.path));
if (info.foreach != null) {
u.put("foreach", replace(project, info.foreach));
}
@ -194,7 +194,7 @@ class DashboardsCollection implements
}
private static String defaultOf(Project proj) {
final String defaultId = Objects.firstNonNull(
final String defaultId = MoreObjects.firstNonNull(
proj.getLocalDefaultDashboard(),
Strings.nullToEmpty(proj.getDefaultDashboard()));
if (defaultId.startsWith(REFS_DASHBOARDS)) {

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.project;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.common.ProjectUtil;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GroupDescription;
@ -187,7 +187,7 @@ public class PerformCreateProject {
Project newProject = config.getProject();
newProject.setDescription(createProjectArgs.projectDescription);
newProject.setSubmitType(Objects.firstNonNull(createProjectArgs.submitType,
newProject.setSubmitType(MoreObjects.firstNonNull(createProjectArgs.submitType,
cfg.getEnum("repository", "*", "defaultSubmitType", SubmitType.MERGE_IF_NECESSARY)));
newProject
.setUseContributorAgreements(createProjectArgs.contributorAgreements);

View File

@ -14,6 +14,7 @@
package com.google.gerrit.server.project;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.gerrit.common.ChangeHooks;
@ -85,7 +86,7 @@ class PutDescription implements RestModifyView<ProjectResource, Input> {
Project project = config.getProject();
project.setDescription(Strings.emptyToNull(input.description));
String msg = Objects.firstNonNull(
String msg = MoreObjects.firstNonNull(
Strings.emptyToNull(input.commitMessage),
"Updated description.\n");
if (!msg.endsWith("\n")) {

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.project;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
@ -97,7 +97,7 @@ class SetDefaultDashboard implements RestModifyView<DashboardResource, Input> {
project.setLocalDefaultDashboard(input.id);
}
String msg = Objects.firstNonNull(
String msg = MoreObjects.firstNonNull(
Strings.emptyToNull(input.commitMessage),
input.id == null
? "Removed default dashboard.\n"

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.project;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
@ -77,7 +77,8 @@ public class SetParent implements RestModifyView<ProjectResource, Input> {
if (msg == null) {
msg = String.format(
"Changed parent to %s.\n",
Objects.firstNonNull(project.getParentName(), allProjects.get()));
MoreObjects.firstNonNull(project.getParentName(),
allProjects.get()));
} else if (!msg.endsWith("\n")) {
msg += "\n";
}

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.query.change;
import static com.google.gerrit.server.ApprovalsUtil.sortApprovals;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
@ -553,7 +553,7 @@ public class ChangeData {
@Override
public String toString() {
return Objects.toStringHelper(this).addValue(getId()).toString();
return MoreObjects.toStringHelper(this).addValue(getId()).toString();
}
public static class ChangedLines {

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.query.change;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.gerrit.common.data.GlobalCapability;
@ -416,7 +416,7 @@ public class QueryProcessor {
}
private int limit(Predicate<ChangeData> s) {
int n = Objects.firstNonNull(ChangeQueryBuilder.getLimit(s), maxLimit);
int n = MoreObjects.firstNonNull(ChangeQueryBuilder.getLimit(s), maxLimit);
return limit > 0 ? Math.min(n, limit) + 1 : n + 1;
}

View File

@ -18,7 +18,7 @@ import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.group.SystemGroupBackend.PROJECT_OWNERS;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.common.Version;
@ -126,7 +126,7 @@ public class AllProjectsCreator {
git);
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
md.setMessage(Objects.firstNonNull(
md.setMessage(MoreObjects.firstNonNull(
Strings.emptyToNull(message),
"Initialized Gerrit Code Review " + Version.getVersion()));

View File

@ -14,6 +14,7 @@
package com.google.gerrit.server.securestore;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import java.io.File;
@ -57,7 +58,7 @@ public class SecureStoreData {
@Override
public String toString() {
return Objects.toStringHelper(this).add("storeName", storeName)
return MoreObjects.toStringHelper(this).add("storeName", storeName)
.add("className", className).add("file", pluginFile).toString();
}

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.util;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.errors.NotSignedInException;
import com.google.gerrit.reviewdb.server.ReviewDb;
@ -48,7 +48,7 @@ public class ThreadLocalRequestContext {
@Provides
RequestContext provideRequestContext(
@Named(FALLBACK) RequestContext fallback) {
return Objects.firstNonNull(local.get(), fallback);
return MoreObjects.firstNonNull(local.get(), fallback);
}
@Provides

View File

@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.gerrit.common.changes.Side;
@ -430,7 +430,7 @@ public class CommentsTest {
}
assertEquals(plc.getLine(), (int) ci.line);
assertEquals(plc.getSide() == 0 ? Side.PARENT : Side.REVISION,
Objects.firstNonNull(ci.side, Side.REVISION));
MoreObjects.firstNonNull(ci.side, Side.REVISION));
assertEquals(TimeUtil.roundToSecond(plc.getWrittenOn()),
TimeUtil.roundToSecond(ci.updated));
assertEquals(plc.getRange(), ci.range);

View File

@ -21,7 +21,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
@ -904,7 +904,7 @@ public abstract class AbstractQueryChangesTest {
commit = repo.parseBody(repo.commit().message("message").create());
}
Account.Id ownerId = owner != null ? new Account.Id(owner) : userId;
branch = Objects.firstNonNull(branch, "refs/heads/master");
branch = MoreObjects.firstNonNull(branch, "refs/heads/master");
if (!branch.startsWith("refs/heads/")) {
branch = "refs/heads/" + branch;
}

View File

@ -19,7 +19,7 @@ import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import org.junit.runner.Runner;
@ -111,7 +111,7 @@ public class ConfigSuite extends Suite {
@Override
protected String getName() {
return Objects.firstNonNull(name, DEFAULT);
return MoreObjects.firstNonNull(name, DEFAULT);
}
@Override

View File

@ -16,7 +16,7 @@ package com.google.gerrit.sshd.commands;
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.reviewdb.client.AccountGroup;
@ -79,7 +79,7 @@ public class ListGroupsCommand extends SshCommand {
void display(final PrintWriter out) throws OrmException {
final ColumnFormatter formatter = new ColumnFormatter(out, '\t');
for (final GroupInfo info : get()) {
formatter.addColumn(Objects.firstNonNull(info.name, "n/a"));
formatter.addColumn(MoreObjects.firstNonNull(info.name, "n/a"));
if (verboseOutput) {
AccountGroup o = info.ownerId != null
? groupCache.get(new AccountGroup.UUID(Url.decode(info.ownerId)))
@ -89,7 +89,7 @@ public class ListGroupsCommand extends SshCommand {
formatter.addColumn(Strings.nullToEmpty(info.description));
formatter.addColumn(o != null ? o.getName() : "n/a");
formatter.addColumn(o != null ? o.getGroupUUID().get() : "");
formatter.addColumn(Boolean.toString(Objects.firstNonNull(
formatter.addColumn(Boolean.toString(MoreObjects.firstNonNull(
info.options.visibleToAll, Boolean.FALSE)));
}
formatter.nextLine();

View File

@ -16,7 +16,7 @@ package com.google.gerrit.sshd.commands;
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.reviewdb.client.AccountGroup;
@ -95,10 +95,11 @@ public class ListMembersCommand extends SshCommand {
}
formatter.addColumn(member._id.toString());
formatter.addColumn(Objects.firstNonNull(member.username, "n/a"));
formatter.addColumn(Objects.firstNonNull(
formatter.addColumn(MoreObjects.firstNonNull(
member.username, "n/a"));
formatter.addColumn(MoreObjects.firstNonNull(
Strings.emptyToNull(member.name), "n/a"));
formatter.addColumn(Objects.firstNonNull(member.email, "n/a"));
formatter.addColumn(MoreObjects.firstNonNull(member.email, "n/a"));
formatter.nextLine();
}

View File

@ -16,7 +16,7 @@ package com.google.gerrit.sshd.commands;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.restapi.IdString;
@ -119,7 +119,7 @@ public class SetMembersCommand extends SshCommand {
new Function<Account.Id, String>() {
@Override
public String apply(Account.Id accountId) {
return Objects.firstNonNull(accountCache.get(accountId)
return MoreObjects.firstNonNull(accountCache.get(accountId)
.getAccount().getPreferredEmail(), "n/a");
}
}))).getBytes(ENC));

View File

@ -16,7 +16,7 @@ package com.google.gerrit.sshd.commands;
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.ConfigResource;
@ -108,7 +108,7 @@ final class ShowQueue extends SshCommand {
stdout.print(String.format("%8s %-12s %-4s %s\n",
task.id, start, startTime(task.startTime),
Objects.firstNonNull(remoteName, "n/a")));
MoreObjects.firstNonNull(remoteName, "n/a")));
}
}
stdout.print("----------------------------------------------"