Factor out RevisionJson from ChangeJson
ChangeJson has grow in size and became very hard to read. This commit is
a first step at modularizing the logic by factoring out RevisionJson.
It makes the concept of lazyloading purely internal to
{Change,Revision}Json by removing the parameter and deriving the
parameter based on the provided options only.
Change-Id: Ie04ec27723d145518277c84970462ab0e6c01979
This commit is contained in:
@@ -14,9 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -136,10 +134,7 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
||||
|
||||
ChangeJson cjson = json.create(options);
|
||||
cjson.setPluginDefinedAttributesFactory(this.imp);
|
||||
List<List<ChangeInfo>> res =
|
||||
cjson
|
||||
.lazyLoad(containsAnyOf(options, ChangeJson.REQUIRE_LAZY_LOAD))
|
||||
.formatQueryResults(results);
|
||||
List<List<ChangeInfo>> res = cjson.formatQueryResults(results);
|
||||
|
||||
for (int n = 0; n < cnt; n++) {
|
||||
List<ChangeInfo> info = res.get(n);
|
||||
@@ -149,9 +144,4 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static boolean containsAnyOf(
|
||||
EnumSet<ListChangesOption> set, ImmutableSet<ListChangesOption> toFind) {
|
||||
return !Sets.intersection(toFind, set).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user