diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
commit | c1c373f4278426308689db61f7758185e8f0401b (patch) | |
tree | 9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /util/src/main | |
parent | a508fd5315c6330f2057c219aebc35b15d0ea497 (diff) | |
download | aspectj-c1c373f4278426308689db61f7758185e8f0401b.tar.gz aspectj-c1c373f4278426308689db61f7758185e8f0401b.zip |
'String.indexOf()' expression is replaceable with 'contains()'
Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'util/src/main')
-rw-r--r-- | util/src/main/java/org/aspectj/util/FileUtil.java | 2 | ||||
-rw-r--r-- | util/src/main/java/org/aspectj/util/LangUtil.java | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java index 6e55742b1..1927f47a0 100644 --- a/util/src/main/java/org/aspectj/util/FileUtil.java +++ b/util/src/main/java/org/aspectj/util/FileUtil.java @@ -1404,7 +1404,7 @@ public class FileUtil { /** @return true if input is not null and contains no path separator */ private static boolean isValidFileName(String input) { - return ((null != input) && (-1 == input.indexOf(File.pathSeparator))); + return ((null != input) && (!input.contains(File.pathSeparator))); } private static void listFiles(final File baseDir, String dir, ArrayList<String> result) { diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index a0967cfcc..49a65df52 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -356,7 +356,7 @@ public class LangUtil { } ArrayList<String> result = new ArrayList<String>(); - if (LangUtil.isEmpty(delim) || (-1 == input.indexOf(delim))) { + if (LangUtil.isEmpty(delim) || (!input.contains(delim))) { result.add(input.trim()); } else { StringTokenizer st = new StringTokenizer(input, delim); @@ -1018,7 +1018,7 @@ public class LangUtil { boolean result = false; if (!LangUtil.isEmpty(input)) { for (int i = 0; !result && (i < infixes.length); i++) { - result = (-1 != input.indexOf(infixes[i])); + result = (input.contains(infixes[i])); } } return result; |