From 23b98110245b828e4c0eaef520335019f7ec6e3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 6 Jan 2013 16:00:28 +0100 Subject: [PATCH] Extract reaction name from file name. --- .../java/net/pterodactylus/reactor/loader/ChainWatcher.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java b/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java index 9daf262..4a18a3e 100644 --- a/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java +++ b/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java @@ -142,7 +142,7 @@ public class ChainWatcher extends AbstractExecutionThreadService { logger.debug(String.format(" Parameter: %s=%s", parameter.name(), parameter.value())); } - chains.put(configurationFile.getName(), chain); + chains.put(getReactionName(configurationFile.getName()), chain); } /* filter enabled chains. */ @@ -212,4 +212,15 @@ public class ChainWatcher extends AbstractExecutionThreadService { return null; } + /** + * Extracts the name of the reaction from the given filename. + * + * @param filename + * The filename to extract the reaction name from + * @return The name of the reaction + */ + private static String getReactionName(String filename) { + return (filename.lastIndexOf(".") > -1) ? filename.substring(0, filename.lastIndexOf(".")) : filename; + } + } -- 2.7.4