diff --git a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java index fdb91220b..c6af33a06 100644 --- a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java @@ -295,8 +295,8 @@ public class CharSequenceUtils { } // The real same check as in String.regionMatches(): - char u1 = Character.toUpperCase(c1); - char u2 = Character.toUpperCase(c2); + final char u1 = Character.toUpperCase(c1); + final char u2 = Character.toUpperCase(c2); if (u1 != u2 && Character.toLowerCase(u1) != Character.toLowerCase(u2)) { return false; } diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 1ae2e38e4..5b8723016 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -6693,8 +6693,8 @@ public class StringUtils { // if recursing, this shouldn't be less than 0 if (timeToLive < 0) { - Set searchSet = new HashSet<>(Arrays.asList(searchList)); - Set replacementSet = new HashSet<>(Arrays.asList(replacementList)); + final Set searchSet = new HashSet<>(Arrays.asList(searchList)); + final Set replacementSet = new HashSet<>(Arrays.asList(replacementList)); searchSet.retainAll(replacementSet); if (searchSet.size() > 0) { throw new IllegalStateException("Aborting to protect against StackOverflowError - " + @@ -8277,7 +8277,7 @@ public class StringUtils { * @return the stripped Strings, {@code null} if null array input */ public static String[] stripAll(final String[] strs, final String stripChars) { - int strsLen = ArrayUtils.getLength(strs); + final int strsLen = ArrayUtils.getLength(strs); if (strsLen == 0) { return strs; } diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java index 4856c32c3..56fda5556 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java @@ -627,7 +627,7 @@ public abstract class ToStringStyle implements Serializable { if (coll != null && !coll.isEmpty()) { buffer.append(arrayStart); int i = 0; - for (Object item : coll) { + for (final Object item : coll) { appendDetail(buffer, fieldName, i++, item); } buffer.append(arrayEnd); @@ -944,7 +944,7 @@ public abstract class ToStringStyle implements Serializable { * @param item the array item to add * @since 3.11 */ - protected void appendDetail(final StringBuffer buffer, final String fieldName, int i, final Object item) { + protected void appendDetail(final StringBuffer buffer, final String fieldName, final int i, final Object item) { if (i > 0) { buffer.append(arraySeparator); } diff --git a/src/test/java/org/apache/commons/lang3/FunctionsTest.java b/src/test/java/org/apache/commons/lang3/FunctionsTest.java index 798591294..cd0607de7 100644 --- a/src/test/java/org/apache/commons/lang3/FunctionsTest.java +++ b/src/test/java/org/apache/commons/lang3/FunctionsTest.java @@ -76,17 +76,17 @@ public class FunctionsTest { return true; } - static boolean testDouble(double value) throws SomeException { + static boolean testDouble(final double value) throws SomeException { throwOnOdd(); return true; } - static boolean testInt(int value) throws SomeException { + static boolean testInt(final int value) throws SomeException { throwOnOdd(); return true; } - static boolean testLong(long value) throws SomeException { + static boolean testLong(final long value) throws SomeException { throwOnOdd(); return true; } @@ -159,7 +159,7 @@ public class FunctionsTest { test(throwable); } - public Object test(Object input1, Object input2) throws Throwable { + public Object test(final Object input1, final Object input2) throws Throwable { test(throwable); return acceptedObject; } @@ -225,41 +225,41 @@ public class FunctionsTest { return 0; } - public void testDouble(double i) throws Throwable { + public void testDouble(final double i) throws Throwable { test(throwable); acceptedPrimitiveObject1 = (P) ((Double) i); } - public double testDoubleDouble(double i, double j) throws Throwable { + public double testDoubleDouble(final double i, final double j) throws Throwable { test(throwable); acceptedPrimitiveObject1 = (P) ((Double) i); acceptedPrimitiveObject2 = (P) ((Double) j); return 3d; } - public void testInt(int i) throws Throwable { + public void testInt(final int i) throws Throwable { test(throwable); acceptedPrimitiveObject1 = (P) ((Integer) i); } - public void testLong(long i) throws Throwable { + public void testLong(final long i) throws Throwable { test(throwable); acceptedPrimitiveObject1 = (P) ((Long) i); } - public void testObjDouble(T object, double i) throws Throwable { + public void testObjDouble(final T object, final double i) throws Throwable { test(throwable); acceptedObject = object; acceptedPrimitiveObject1 = (P) ((Double) i); } - public void testObjInt(T object, int i) throws Throwable { + public void testObjInt(final T object, final int i) throws Throwable { test(throwable); acceptedObject = object; acceptedPrimitiveObject1 = (P) ((Integer) i); } - public void testObjLong(T object, long i) throws Throwable { + public void testObjLong(final T object, final long i) throws Throwable { test(throwable); acceptedObject = object; acceptedPrimitiveObject1 = (P) ((Long) i); @@ -800,7 +800,7 @@ public class FunctionsTest { new Functions.FailableBiConsumer() { @Override - public void accept(Object object1, Object object2) throws Throwable { + public void accept(final Object object1, final Object object2) throws Throwable { throw new IOException("test"); } }; @@ -815,7 +815,7 @@ public class FunctionsTest { new Functions.FailableBiConsumer() { @Override - public void accept(String object1, String object2) throws IOException { + public void accept(final String object1, final String object2) throws IOException { throw new IOException("test"); } @@ -831,7 +831,7 @@ public class FunctionsTest { new Functions.FailableBiFunction() { @Override - public Object apply(Object input1, Object input2) throws Throwable { + public Object apply(final Object input1, final Object input2) throws Throwable { throw new IOException("test"); } }; @@ -846,7 +846,7 @@ public class FunctionsTest { new Functions.FailableBiFunction() { @Override - public String apply(String input1, String input2) throws IOException { + public String apply(final String input1, final String input2) throws IOException { throw new IOException("test"); } }; @@ -861,7 +861,7 @@ public class FunctionsTest { new Functions.FailableBiPredicate() { @Override - public boolean test(Object object1, Object object2) throws Throwable { + public boolean test(final Object object1, final Object object2) throws Throwable { throw new IOException("test"); } }; @@ -876,7 +876,7 @@ public class FunctionsTest { new Functions.FailableBiPredicate() { @Override - public boolean test(String object1, String object2) throws IOException { + public boolean test(final String object1, final String object2) throws IOException { throw new IOException("test"); } }; @@ -921,7 +921,7 @@ public class FunctionsTest { new Functions.FailableConsumer() { @Override - public void accept(Object object) throws Throwable { + public void accept(final Object object) throws Throwable { throw new IOException("test"); } @@ -937,7 +937,7 @@ public class FunctionsTest { new Functions.FailableConsumer() { @Override - public void accept(String object) throws IOException { + public void accept(final String object) throws IOException { throw new IOException("test"); } @@ -953,7 +953,7 @@ public class FunctionsTest { new Functions.FailableFunction() { @Override - public Object apply(Object input) throws Throwable { + public Object apply(final Object input) throws Throwable { throw new IOException("test"); } }; @@ -968,7 +968,7 @@ public class FunctionsTest { new Functions.FailableFunction() { @Override - public String apply(String input) throws IOException { + public String apply(final String input) throws IOException { throw new IOException("test"); } }; @@ -983,7 +983,7 @@ public class FunctionsTest { new Functions.FailablePredicate() { @Override - public boolean test(Object object) throws Throwable { + public boolean test(final Object object) throws Throwable { throw new IOException("test"); } }; @@ -998,7 +998,7 @@ public class FunctionsTest { new Functions.FailablePredicate() { @Override - public boolean test(String object) throws IOException { + public boolean test(final String object) throws IOException { throw new IOException("test"); } }; diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 622cad566..7c657d0f8 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -60,11 +60,11 @@ public class StringUtilsTest { static final String NON_TRIMMABLE; static { - StringBuilder ws = new StringBuilder(); - StringBuilder nws = new StringBuilder(); + final StringBuilder ws = new StringBuilder(); + final StringBuilder nws = new StringBuilder(); final String hs = String.valueOf(((char) 160)); - StringBuilder tr = new StringBuilder(); - StringBuilder ntr = new StringBuilder(); + final StringBuilder tr = new StringBuilder(); + final StringBuilder ntr = new StringBuilder(); for (int i = 0; i < Character.MAX_VALUE; i++) { if (Character.isWhitespace((char) i)) { ws.append(String.valueOf((char) i)); @@ -3310,25 +3310,25 @@ public class StringUtilsTest { @Test public void testGeorgianSample() { - char[] arrayI = new char[]{ + final char[] arrayI = new char[]{ //Latin Small Letter dotless I (char) 0x0131, //Greek Capital Letter Theta (char) 0x03F4 }; - char[] arrayJ = new char[]{ + final char[] arrayJ = new char[]{ //Latin Capital Letter I with dot above (char) 0x0130, //Greek Theta Symbol (char) 0x03D1 }; - for (char i : arrayI) { - for (char j : arrayJ) { - String si = String.valueOf(i); - String sj = String.valueOf(j); - boolean res1 = si.equalsIgnoreCase(sj); - CharSequence ci = new StringBuilder(si); - CharSequence cj = new StringBuilder(sj); + for (final char i : arrayI) { + for (final char j : arrayJ) { + final String si = String.valueOf(i); + final String sj = String.valueOf(j); + final boolean res1 = si.equalsIgnoreCase(sj); + final CharSequence ci = new StringBuilder(si); + final CharSequence cj = new StringBuilder(sj); boolean res2 = StringUtils.startsWithIgnoreCase(ci, cj); assertEquals(res1, res2, "si : " + si + " sj : " + sj); res2 = StringUtils.endsWithIgnoreCase(ci, cj); diff --git a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java index 623ddb90a..23895118a 100644 --- a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java @@ -186,8 +186,8 @@ public class JsonToStringStyleTest { @Test public void testList() { - Student student = new Student(); - ArrayList objects = new ArrayList<>(); + final Student student = new Student(); + final ArrayList objects = new ArrayList<>(); objects.add(Hobby.BOOK); objects.add(Hobby.SPORT); @@ -204,8 +204,8 @@ public class JsonToStringStyleTest { @Test public void testArrayEnum() { - Teacher teacher = new Teacher(); - Hobby[] hobbies = new Hobby[3]; + final Teacher teacher = new Teacher(); + final Hobby[] hobbies = new Hobby[3]; hobbies[0] = Hobby.BOOK; hobbies[1] = Hobby.SPORT; hobbies[2] = Hobby.MUSIC; @@ -221,30 +221,30 @@ public class JsonToStringStyleTest { @Test public void testCombineListAndEnum() { - Teacher teacher = new Teacher(); + final Teacher teacher = new Teacher(); - Hobby[] teacherHobbies = new Hobby[3]; + final Hobby[] teacherHobbies = new Hobby[3]; teacherHobbies[0] = Hobby.BOOK; teacherHobbies[1] = Hobby.SPORT; teacherHobbies[2] = Hobby.MUSIC; teacher.setHobbies(teacherHobbies); - Student john = new Student(); + final Student john = new Student(); john.setHobbies(Arrays.asList(Hobby.BOOK, Hobby.MUSIC)); - Student alice = new Student(); + final Student alice = new Student(); alice.setHobbies(new ArrayList<>()); - Student bob = new Student(); + final Student bob = new Student(); bob.setHobbies(Collections.singletonList(Hobby.BOOK)); - ArrayList students = new ArrayList<>(); + final ArrayList students = new ArrayList<>(); students.add(john); students.add(alice); students.add(bob); - AcademyClass academyClass = new AcademyClass(); + final AcademyClass academyClass = new AcademyClass(); academyClass.setStudents(students); academyClass.setTeacher(teacher); @@ -564,7 +564,7 @@ public class JsonToStringStyleTest { return hobbies; } - public void setHobbies(List hobbies) { + public void setHobbies(final List hobbies) { this.hobbies = hobbies; } @@ -581,7 +581,7 @@ public class JsonToStringStyleTest { return hobbies; } - public void setHobbies(Hobby[] hobbies) { + public void setHobbies(final Hobby[] hobbies) { this.hobbies = hobbies; } @@ -595,11 +595,11 @@ public class JsonToStringStyleTest { Teacher teacher; List students; - public void setTeacher(Teacher teacher) { + public void setTeacher(final Teacher teacher) { this.teacher = teacher; } - public void setStudents(List students) { + public void setStudents(final List students) { this.students = students; } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/LocksTest.java b/src/test/java/org/apache/commons/lang3/concurrent/LocksTest.java index 461bb539e..2d577ecdb 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/LocksTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/LocksTest.java @@ -44,7 +44,7 @@ public class LocksTest { runTest(DELAY, true, l -> assertTrue(l >= NUMBER_OF_THREADS*DELAY)); } - private void runTest(long delay, boolean exclusiveLock, LongConsumer runTimeCheck) throws InterruptedException { + private void runTest(final long delay, final boolean exclusiveLock, final LongConsumer runTimeCheck) throws InterruptedException { final boolean[] booleanValues = new boolean[10]; final Lock lock = Locks.lock(booleanValues); final boolean[] runningValues = new boolean[10]; @@ -78,13 +78,13 @@ public class LocksTest { runTimeCheck.accept(endTime-startTime); } - protected void modify(boolean[] booleanArray, int offset, boolean value) { + protected void modify(final boolean[] booleanArray, final int offset, final boolean value) { synchronized(booleanArray) { booleanArray[offset] = value; } } - protected boolean someValueIsTrue(boolean[] booleanArray) { + protected boolean someValueIsTrue(final boolean[] booleanArray) { synchronized(booleanArray) { for (int i = 0; i < booleanArray.length; i++) { if (booleanArray[i]) {