diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-11 09:32:59 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-11 09:32:59 -0400 |
| commit | f9283a20abd9eaed0b0436bc54c60576233121f4 (patch) | |
| tree | cec1323fb3faf1a4dcee2394a114b821c2366166 /BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java | |
| parent | 275a627719fc2231b16caea41130ff09f0f2b6a1 (diff) | |
Added new method to pairs and holders
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java index a73292c..ac36d15 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java @@ -37,4 +37,24 @@ public class StringUtils { return input.matches("\\A(?:" + regex + ")+\\Z"); } + /** + * Checks if the given expression contains the specified operator in a + * situation that indicates its use as an infix operator. + * + * @param expression + * The expression to check + * @param operator + * The operator to see if it is contained + * @return Whether or not the given expression contains the specified + * operator as a infix operator + */ + public static boolean containsInfixOperator(String expression, + String operator) { + // Bit annoying to have to use a full class name, but what are you + // going to do? + return org.apache.commons.lang3.StringUtils + .countMatches(expression, operator) == 1 + && !expression.equalsIgnoreCase(operator) + && !expression.startsWith(operator); + } } |
