From c40a60e937c48a4937b7462208645e799bbcb478 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Fri, 24 Aug 2018 08:56:01 -0400 Subject: [PATCH] [JENKINS-53177] - Promote ConsoleAnnotatorAggregator to try to fix Anonymous complaint (#3598) JENKINS-53177 --- .../java/hudson/console/ConsoleAnnotator.java | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/hudson/console/ConsoleAnnotator.java b/core/src/main/java/hudson/console/ConsoleAnnotator.java index c19ac974b6..475badceb6 100644 --- a/core/src/main/java/hudson/console/ConsoleAnnotator.java +++ b/core/src/main/java/hudson/console/ConsoleAnnotator.java @@ -91,41 +91,42 @@ public abstract class ConsoleAnnotator implements Serializable { return (ConsoleAnnotator)a; } - /** - * Bundles all the given {@link ConsoleAnnotator} into a single annotator. - */ - public static ConsoleAnnotator combine(Collection> all) { - switch (all.size()) { - case 0: return null; // none - case 1: return cast(all.iterator().next()); // just one - } - - class Aggregator extends ConsoleAnnotator { - List> list; + private static final class ConsoleAnnotatorAggregator extends ConsoleAnnotator { + List> list; - Aggregator(Collection list) { - this.list = new ArrayList>(list); - } + ConsoleAnnotatorAggregator(Collection list) { + this.list = new ArrayList>(list); + } - public ConsoleAnnotator annotate(T context, MarkupText text) { - ListIterator> itr = list.listIterator(); - while (itr.hasNext()) { - ConsoleAnnotator a = itr.next(); - ConsoleAnnotator b = a.annotate(context,text); - if (a!=b) { - if (b==null) itr.remove(); - else itr.set(b); - } + public ConsoleAnnotator annotate(T context, MarkupText text) { + ListIterator> itr = list.listIterator(); + while (itr.hasNext()) { + ConsoleAnnotator a = itr.next(); + ConsoleAnnotator b = a.annotate(context,text); + if (a!=b) { + if (b==null) itr.remove(); + else itr.set(b); } + } - switch (list.size()) { + switch (list.size()) { case 0: return null; // no more annotator left case 1: return list.get(0); // no point in aggregating default: return this; - } } } - return new Aggregator(all); + } + + /** + * Bundles all the given {@link ConsoleAnnotator} into a single annotator. + */ + public static ConsoleAnnotator combine(Collection> all) { + switch (all.size()) { + case 0: return null; // none + case 1: return cast(all.iterator().next()); // just one + } + + return new ConsoleAnnotatorAggregator(all); } /** -- GitLab