diff options
author | Luck <git@lucko.me> | 2018-11-04 01:05:41 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2018-11-04 01:05:41 +0000 |
commit | 320d6a28b60873c8e8163b27ed1389978aed4ee6 (patch) | |
tree | ba130d567e58883458411d115a6eac1b8688220a /spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java | |
parent | 9e4c0edc47707fbcad34305b3cd723b08f1ab4d6 (diff) | |
download | spark-320d6a28b60873c8e8163b27ed1389978aed4ee6.tar.gz spark-320d6a28b60873c8e8163b27ed1389978aed4ee6.tar.bz2 spark-320d6a28b60873c8e8163b27ed1389978aed4ee6.zip |
some misc refactoring
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java b/spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java index 0707df6..72cd4dc 100644 --- a/spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java +++ b/spark-common/src/main/java/me/lucko/spark/sampler/ThreadGrouper.java @@ -40,33 +40,24 @@ public interface ThreadGrouper { /** * Implementation of {@link ThreadGrouper} that just groups by thread name. */ - ThreadGrouper BY_NAME = new ByName(); - - final class ByName implements ThreadGrouper { - @Override - public String getGroup(String threadName) { - return threadName; - } - } + ThreadGrouper BY_NAME = threadName -> threadName; /** * Implementation of {@link ThreadGrouper} that attempts to group by the name of the pool * the thread originated from. */ - ThreadGrouper BY_POOL = new ByPool(); - - final class ByPool implements ThreadGrouper { - private static final Pattern THREAD_POOL_PATTERN = Pattern.compile("^(.*)[-#] ?\\d+$"); + ThreadGrouper BY_POOL = new ThreadGrouper() { + private final Pattern pattern = Pattern.compile("^(.*)[-#] ?\\d+$"); @Override public String getGroup(String threadName) { - Matcher matcher = THREAD_POOL_PATTERN.matcher(threadName); + Matcher matcher = this.pattern.matcher(threadName); if (!matcher.matches()) { return threadName; } return matcher.group(1).trim() + " (Combined)"; } - } + }; } |