Merge "Drop LabelType.getPosition()"
This commit is contained in:
@@ -352,7 +352,7 @@ public class ChangeJson {
|
||||
LabelTypes labelTypes, boolean standard) throws OrmException {
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
Map<String, LabelInfo> labels =
|
||||
new TreeMap<String, LabelInfo>(LabelOrdering.create(labelTypes));
|
||||
new TreeMap<String, LabelInfo>(labelTypes.nameComparator());
|
||||
for (SubmitRecord rec : submitRecords(cd)) {
|
||||
if (rec.labels == null) {
|
||||
continue;
|
||||
@@ -485,7 +485,7 @@ public class ChangeJson {
|
||||
//
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
Map<String, LabelInfo> labels =
|
||||
new TreeMap<String, LabelInfo>(LabelOrdering.create(labelTypes));
|
||||
new TreeMap<String, LabelInfo>(labelTypes.nameComparator());
|
||||
for (ApprovalCategory.Id id : categories) {
|
||||
LabelType type = labelTypes.byId(id.get());
|
||||
if (type != null) {
|
||||
|
@@ -1,36 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
|
||||
class LabelOrdering {
|
||||
public static Ordering<String> create(final LabelTypes labelTypes) {
|
||||
return Ordering.natural().nullsLast().onResultOf(
|
||||
new Function<String, Short>() {
|
||||
@Override
|
||||
public Short apply(String n) {
|
||||
LabelType lt = labelTypes.byLabel(n);
|
||||
return lt != null ? lt.getPosition() : null;
|
||||
}
|
||||
}).compound(Ordering.natural());
|
||||
}
|
||||
|
||||
private LabelOrdering() {
|
||||
}
|
||||
}
|
@@ -88,8 +88,7 @@ public class ReviewerJson {
|
||||
}
|
||||
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
out.approvals = new TreeMap<String,String>(LabelOrdering.create(
|
||||
labelTypes));
|
||||
out.approvals = new TreeMap<String,String>(labelTypes.nameComparator());
|
||||
for (PatchSetApproval ca : approvals) {
|
||||
for (PermissionRange pr : ctl.getLabelRanges()) {
|
||||
if (!pr.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user