summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2018-06-08 14:32:40 +0200
committerMartin Polden <mpolden@mpolden.no>2018-06-08 15:01:29 +0200
commitda5ee91aaf26b33bd4352ebe992829afa0ad145b (patch)
tree120af7a39e28925a4e6095b4ebc97cfa20c8f639
parent9fa71da75e98f8486884a45ef4035763997fd620 (diff)
Allow multiple issue labels
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java34
1 files changed, 23 insertions, 11 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java
index 37356f2c2a6..086487b8be7 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Issue.java
@@ -1,8 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.organization;
+import com.google.common.collect.ImmutableList;
import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -16,46 +20,54 @@ public class Issue {
private final String summary;
private final String description;
- private final String label;
+ private final List<String> labels;
private final User assignee;
private final PropertyId propertyId;
private final Type type;
- private Issue(String summary, String description, String label, User assignee, PropertyId propertyId, Type type) {
+ private Issue(String summary, String description, List<String> labels, User assignee, PropertyId propertyId, Type type) {
if (summary.isEmpty()) throw new IllegalArgumentException("Issue summary can not be empty!");
if (description.isEmpty()) throw new IllegalArgumentException("Issue description can not be empty!");
Objects.requireNonNull(propertyId, "An issue must belong to a property!");
this.summary = summary;
this.description = description;
- this.label = label;
+ this.labels = ImmutableList.copyOf(labels);
this.assignee = assignee;
this.propertyId = propertyId;
this.type = type;
}
public Issue(String summary, String description, PropertyId propertyId) {
- this(summary, description, null, null, propertyId, Type.defect);
+ this(summary, description, Collections.emptyList(), null, propertyId, Type.defect);
}
public Issue append(String appendage) {
- return new Issue(summary, description + appendage, label, assignee, propertyId, type);
+ return new Issue(summary, description + appendage, labels, assignee, propertyId, type);
}
public Issue with(String label) {
- return new Issue(summary, description, label, assignee, propertyId, type);
+ List<String> labels = new ArrayList<>(this.labels);
+ labels.add(label);
+ return new Issue(summary, description, labels, assignee, propertyId, type);
+ }
+
+ public Issue with(List<String> labels) {
+ List<String> newLabels = new ArrayList<>(this.labels);
+ newLabels.addAll(labels);
+ return new Issue(summary, description, newLabels, assignee, propertyId, type);
}
public Issue with(User assignee) {
- return new Issue(summary, description, label, assignee, propertyId, type);
+ return new Issue(summary, description, labels, assignee, propertyId, type);
}
public Issue with(PropertyId propertyId) {
- return new Issue(summary, description, label, assignee, propertyId, type);
+ return new Issue(summary, description, labels, assignee, propertyId, type);
}
public Issue with(Type type) {
- return new Issue(summary, description, label, assignee, propertyId, type);
+ return new Issue(summary, description, labels, assignee, propertyId, type);
}
public String summary() {
@@ -66,8 +78,8 @@ public class Issue {
return description;
}
- public Optional<String> label() {
- return Optional.ofNullable(label);
+ public List<String> labels() {
+ return labels;
}
public Optional<User> assignee() {