summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-14 12:07:14 -0400
committerEVE <EVE@EVE-PC>2017-03-14 12:07:14 -0400
commit504ca816530efdff06bc202e0432ebd354aec304 (patch)
tree4836932fb81d1d625470502c78c94d202c9a7420 /BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
parent5c1163df17c46f7d3e15b6c7949c38843ec56146 (diff)
Cleanup
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
index 151b7e2..f550b65 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java
@@ -1,10 +1,10 @@
package bjc.utils.funcutils;
-import java.util.function.BiFunction;
-
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
+import java.util.function.BiFunction;
+
final class TokenDeaffixer implements BiFunction<String, String, IList<String>> {
private String token;
@@ -14,38 +14,34 @@ final class TokenDeaffixer implements BiFunction<String, String, IList<String>>
@Override
public IList<String> apply(String operatorName, String operatorRegex) {
- if (operatorName == null) {
+ if(operatorName == null)
throw new NullPointerException("Operator name must not be null");
- } else if (operatorRegex == null) {
- throw new NullPointerException("Operator regex must not be null");
- }
+ else if(operatorRegex == null) throw new NullPointerException("Operator regex must not be null");
- if (StringUtils.containsOnly(token, operatorRegex)) {
+ if(StringUtils.containsOnly(token, operatorRegex))
return new FunctionalList<>(token);
- } else if (token.startsWith(operatorName)) {
- if (token.endsWith(operatorName)) {
+ else if(token.startsWith(operatorName)) {
+ if(token.endsWith(operatorName))
return new FunctionalList<>(operatorName, token.split(operatorRegex)[1], operatorName);
- }
return new FunctionalList<>(operatorName, token.split(operatorRegex)[1]);
- } else if (token.endsWith(operatorName)) {
+ } else if(token.endsWith(operatorName))
return new FunctionalList<>(token.split(operatorRegex)[0], operatorName);
- } else if (token.contains(operatorName)) {
+ else if(token.contains(operatorName)) {
String[] tokenParts = token.split(operatorRegex);
IList<String> returned = new FunctionalList<>();
- for (int i = 0; i < tokenParts.length; i++) {
+ for(int i = 0; i < tokenParts.length; i++) {
returned.add(tokenParts[i]);
- if (i < tokenParts.length - 1) {
+ if(i < tokenParts.length - 1) {
returned.add(operatorName);
}
}
return returned;
- } else {
+ } else
return new FunctionalList<>(token);
- }
}
}