Use Prolog term none if a min or max is missing
Labels can be missing a min or max value if there are no values defined, or if all of the values are less then or equal to 0. Instead of crashing in PRED_get_legacy_label_types_1 return 'none'. Change-Id: Ie90df66ee4bea4d50befd1b3cb78af9a7456579f
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
package gerrit;
|
package gerrit;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
|
import com.google.gerrit.common.data.LabelValue;
|
||||||
import com.google.gerrit.rules.PrologEnvironment;
|
import com.google.gerrit.rules.PrologEnvironment;
|
||||||
import com.google.gerrit.rules.StoredValues;
|
import com.google.gerrit.rules.StoredValues;
|
||||||
import com.google.gerrit.server.project.ProjectState;
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
@@ -43,6 +44,8 @@ import java.util.List;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
class PRED_get_legacy_label_types_1 extends Predicate.P1 {
|
class PRED_get_legacy_label_types_1 extends Predicate.P1 {
|
||||||
|
private static final SymbolTerm NONE = SymbolTerm.intern("none");
|
||||||
|
|
||||||
PRED_get_legacy_label_types_1(Term a1, Operation n) {
|
PRED_get_legacy_label_types_1(Term a1, Operation n) {
|
||||||
arg1 = a1;
|
arg1 = a1;
|
||||||
cont = n;
|
cont = n;
|
||||||
@@ -75,10 +78,12 @@ class PRED_get_legacy_label_types_1 extends Predicate.P1 {
|
|||||||
"label_type", 4);
|
"label_type", 4);
|
||||||
|
|
||||||
static Term export(LabelType type) {
|
static Term export(LabelType type) {
|
||||||
|
LabelValue min = type.getMin();
|
||||||
|
LabelValue max = type.getMax();
|
||||||
return new StructureTerm(symLabelType,
|
return new StructureTerm(symLabelType,
|
||||||
SymbolTerm.intern(type.getName()),
|
SymbolTerm.intern(type.getName()),
|
||||||
SymbolTerm.intern(type.getFunctionName()),
|
SymbolTerm.intern(type.getFunctionName()),
|
||||||
new IntegerTerm(type.getMin().getValue()),
|
min != null ? new IntegerTerm(min.getValue()) : NONE,
|
||||||
new IntegerTerm(type.getMax().getValue()));
|
max != null ? new IntegerTerm(max.getValue()) : NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user