diff --git a/pom.xml b/pom.xml
index 29efa4e6a..914a6ca20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -339,6 +339,9 @@
This class assists in validating arguments. The validation methods are @@ -48,6 +49,9 @@ import java.util.Map; */ public class Validate { + private static final String DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE = "The value %s is not in the specified exclusive range of %s to %s"; + private static final String DEFAULT_INCLUSIVE_BETWEEN_EX_MESSAGE = "The value %s is not in the specified inclusive range of %s to %s"; + private static final String DEFAULT_MATCHES_PATTERN_EX = "The string %s does not match the pattern %s"; private static final String DEFAULT_IS_NULL_EX_MESSAGE = "The validated object is null"; private static final String DEFAULT_IS_TRUE_EX_MESSAGE = "The validated expression is false"; private static final String DEFAULT_NO_NULL_ELEMENTS_ARRAY_EX_MESSAGE = "The validated array contains null element at index: %d"; @@ -781,5 +785,134 @@ public class Validate { throw new IllegalStateException(String.format(message, values)); } } - + + /** + *
Validate that the specified argument character sequence matches the specified regular + * expression pattern; otherwise throwing an exception.
+ * + *Validate.matchesPattern("hi", "[a-z]*");+ * + *
The syntax of the pattern is the one used in the {@link Pattern} class.
+ * + * @param input the character sequence to validate + * @param pattern regular expression pattern + * @throws IllegalArgumentException if the character sequence does not match the pattern + * @see #matchesPattern(String, String, String, Object...) + */ + public static void matchesPattern(CharSequence input, String pattern) + { + if (Pattern.matches(pattern, input) == false) + { + throw new IllegalArgumentException(String.format(DEFAULT_MATCHES_PATTERN_EX, input, pattern)); + } + } + + /** + *Validate that the specified argument character sequence matches the specified regular + * expression pattern; otherwise throwing an exception with the specified message.
+ * + *Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");+ * + *
The syntax of the pattern is the one used in the {@link Pattern} class.
+ * + * @param input the character sequence to validate + * @param pattern regular expression pattern + * @param message the exception message + * @param optional values to replace in the exception message + * @throws IllegalArgumentException if the character sequence does not match the pattern + * @see #matchesPattern(String, String) + */ + public static void matchesPattern(CharSequence input, String pattern, String message, Object... values) + { + if (Pattern.matches(pattern, input) == false) + { + throw new IllegalArgumentException(String.format(message, values)); + } + } + + /** + *Validate that the specified argument object fall between the two + * inclusive values specified; otherwise, throws an exception.
+ * + *Validate.inclusiveBetween(0, 2, 1);+ * + * @param value the object to validate + * @param start the inclusive start value + * @param end the inclusive end value + * @throws IllegalArgumentException if the value falls out of the boundaries + * @see #inclusiveBetween(Object, Object, Comparable, String, Object...) + */ + public static
Validate that the specified argument object fall between the two + * inclusive values specified; otherwise, throws an exception with the + * specified message.
+ * + *Validate.inclusiveBetween(0, 2, 1, "Not in boundaries");+ * + * @param value the object to validate + * @param start the inclusive start value + * @param end the inclusive end value + * @param message the exception message + * @param optional values to replace in the exception message + * @throws IllegalArgumentException if the value falls out of the boundaries + * @see #inclusiveBetween(Object, Object, Comparable) + */ + public static
Validate that the specified argument object fall between the two + * exclusive values specified; otherwise, throws an exception.
+ * + *Validate.inclusiveBetween(0, 2, 1);+ * + * @param value the object to validate + * @param start the exclusive start value + * @param end the exclusive end value + * @throws IllegalArgumentException if the value falls out of the boundaries + * @see #exclusiveBetween(Object, Object, Comparable, String, Object...) + */ + public static
Validate that the specified argument object fall between the two + * exclusive values specified; otherwise, throws an exception with the + * specified message.
+ * + *Validate.inclusiveBetween(0, 2, 1, "Not in boundaries");+ * + * @param value the object to validate + * @param start the exclusive start value + * @param end the exclusive end value + * @param message the exception message + * @param optional values to replace in the exception message + * @throws IllegalArgumentException if the value falls out of the boundaries + * @see #exclusiveBetween(Object, Object, Comparable) + */ + public static