Consolidate task hint handling Change-Id: I24d61f52cbc7ce59857c793189a54dee2e93b090
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java index 2648701..48109ec 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java +++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java
@@ -159,15 +159,13 @@ if (!options.onlyApplicable) { attribute.applicable = applicable; } - if (node.isDuplicate) { - attribute.hint = "Duplicate task is non blocking and empty to break the loop"; - } else { + if (!node.isDuplicate) { if (task.inProgress != null) { attribute.inProgress = matchCache.matchOrNull(task.inProgress); } - attribute.hint = getHint(attribute.status, task); attribute.exported = task.exported.isEmpty() ? null : task.exported; } + attribute.hint = getHint(attribute.status, task); if (options.evaluationTime) { attribute.evaluationMilliSeconds = millis() - attribute.evaluationMilliSeconds; @@ -310,10 +308,16 @@ } protected String getHint(Status status, Task def) { - if (status == Status.READY) { - return def.readyHint; - } else if (status == Status.FAIL) { - return def.failHint; + if (status != null) { + switch (status) { + case READY: + return def.readyHint; + case FAIL: + return def.failHint; + case DUPLICATE: + return "Duplicate task is non blocking and empty to break the loop"; + default: + } } return null; }