From c63b0923aa6af38dc8c771a7669beb71d48fc8cf Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 8 Jun 2014 16:39:02 +0200 Subject: [PATCH] Add ToolBox.matchesAny method. --- src/fr/devinsy/util/ToolBox.java | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/fr/devinsy/util/ToolBox.java b/src/fr/devinsy/util/ToolBox.java index 33a649c..58cdf9a 100644 --- a/src/fr/devinsy/util/ToolBox.java +++ b/src/fr/devinsy/util/ToolBox.java @@ -169,6 +169,52 @@ public class ToolBox return result; } + /** + * + * @param string + * @param targets + * @return + */ + public static boolean matchesAny(final String string, final String... targets) + { + boolean result; + + if ((string == null) || (targets == null)) + { + result = false; + } + else + { + // + boolean ended = false; + int index = 0; + result = false; + while (!ended) + { + if (index < targets.length) + { + if (StringUtils.equals(string, targets[index])) + { + ended = true; + result = true; + } + else + { + index += 1; + } + } + else + { + ended = true; + result = false; + } + } + } + + // + return result; + } + /** * * @return