From 8efbb7df05d879dec15433e87a51392810936da5 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 1 Sep 2021 14:39:35 -0400 Subject: [PATCH] No leading underscores in private names. --- .../org/apache/commons/lang3/BitField.java | 22 +++++++++---------- .../org/apache/commons/lang3/StringUtils.java | 6 ++--- .../apache/commons/lang3/builder/IDKey.java | 8 +++---- .../commons/lang3/text/FormattableUtils.java | 4 ++-- .../text/translate/LookupTranslator.java | 16 +++++++------- .../lang3/reflect/MethodUtilsTest.java | 7 +++--- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/BitField.java b/src/main/java/org/apache/commons/lang3/BitField.java index dc70df4a5..3f9b4fac4 100644 --- a/src/main/java/org/apache/commons/lang3/BitField.java +++ b/src/main/java/org/apache/commons/lang3/BitField.java @@ -72,8 +72,8 @@ package org.apache.commons.lang3; */ public class BitField { - private final int _mask; - private final int _shift_count; + private final int mask; + private final int shiftCount; /** *

Creates a BitField instance.

@@ -83,8 +83,8 @@ public class BitField { * that this BitField operates on */ public BitField(final int mask) { - _mask = mask; - _shift_count = mask == 0 ? 0 : Integer.numberOfTrailingZeros(mask); + this.mask = mask; + this.shiftCount = mask == 0 ? 0 : Integer.numberOfTrailingZeros(mask); } /** @@ -102,7 +102,7 @@ public class BitField { * @return the selected bits, shifted right appropriately */ public int getValue(final int holder) { - return getRawValue(holder) >> _shift_count; + return getRawValue(holder) >> shiftCount; } /** @@ -131,7 +131,7 @@ public class BitField { * @return the selected bits */ public int getRawValue(final int holder) { - return holder & _mask; + return holder & mask; } /** @@ -159,7 +159,7 @@ public class BitField { * else {@code false} */ public boolean isSet(final int holder) { - return (holder & _mask) != 0; + return (holder & mask) != 0; } /** @@ -175,7 +175,7 @@ public class BitField { * else {@code false} */ public boolean isAllSet(final int holder) { - return (holder & _mask) == _mask; + return (holder & mask) == mask; } /** @@ -189,7 +189,7 @@ public class BitField { * parameter replacing the old bits */ public int setValue(final int holder, final int value) { - return (holder & ~_mask) | ((value << _shift_count) & _mask); + return (holder & ~mask) | ((value << shiftCount) & mask); } /** @@ -215,7 +215,7 @@ public class BitField { * (set to {@code 0}) */ public int clear(final int holder) { - return holder & ~_mask; + return holder & ~mask; } /** @@ -252,7 +252,7 @@ public class BitField { * to {@code 1} */ public int set(final int holder) { - return holder | _mask; + return holder | mask; } /** diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 42d6abfa3..b716711c0 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -2502,7 +2502,7 @@ public class StringUtils { int[] p = new int[n + 1]; // 'previous' cost array, horizontally int[] d = new int[n + 1]; // cost array, horizontally - int[] _d; // placeholder to assist in swapping p and d + int[] tmp; // placeholder to assist in swapping p and d // fill in starting table values final int boundary = Math.min(n, threshold) + 1; @@ -2545,9 +2545,9 @@ public class StringUtils { } // copy current distance counts to 'previous row' distance counts - _d = p; + tmp = p; p = d; - d = _d; + d = tmp; } // if p[n] is greater than the threshold, there's no guarantee on it being the correct diff --git a/src/main/java/org/apache/commons/lang3/builder/IDKey.java b/src/main/java/org/apache/commons/lang3/builder/IDKey.java index 426848a31..64e8fc5b7 100644 --- a/src/main/java/org/apache/commons/lang3/builder/IDKey.java +++ b/src/main/java/org/apache/commons/lang3/builder/IDKey.java @@ -32,15 +32,15 @@ final class IDKey { /** * Constructor for IDKey - * @param _value The value + * @param value The value */ - IDKey(final Object _value) { + IDKey(final Object value) { // This is the Object hash code - id = System.identityHashCode(_value); + this.id = System.identityHashCode(value); // There have been some cases (LANG-459) that return the // same identity hash code for different objects. So // the value is also added to disambiguate these cases. - value = _value; + this.value = value; } /** diff --git a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java index 8934fff93..a369e8067 100644 --- a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java +++ b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java @@ -138,8 +138,8 @@ public class FormattableUtils { "Specified ellipsis '%1$s' exceeds precision of %2$s", ellipsis, Integer.valueOf(precision)); final StringBuilder buf = new StringBuilder(seq); if (precision >= 0 && precision < seq.length()) { - final CharSequence _ellipsis = ObjectUtils.defaultIfNull(ellipsis, StringUtils.EMPTY); - buf.replace(precision - _ellipsis.length(), seq.length(), _ellipsis.toString()); + final CharSequence actualEllipsis = ObjectUtils.defaultIfNull(ellipsis, StringUtils.EMPTY); + buf.replace(precision - actualEllipsis.length(), seq.length(), actualEllipsis.toString()); } final boolean leftJustify = (flags & LEFT_JUSTIFY) == LEFT_JUSTIFY; for (int i = buf.length(); i < width; i++) { diff --git a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java index 5e80154d2..d8f758433 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java @@ -49,23 +49,23 @@ public class LookupTranslator extends CharSequenceTranslator { public LookupTranslator(final CharSequence[]... lookup) { lookupMap = new HashMap<>(); prefixSet = new HashSet<>(); - int _shortest = Integer.MAX_VALUE; - int _longest = 0; + int tmpShortest = Integer.MAX_VALUE; + int tmpLongest = 0; if (lookup != null) { for (final CharSequence[] seq : lookup) { this.lookupMap.put(seq[0].toString(), seq[1].toString()); this.prefixSet.add(seq[0].charAt(0)); final int sz = seq[0].length(); - if (sz < _shortest) { - _shortest = sz; + if (sz < tmpShortest) { + tmpShortest = sz; } - if (sz > _longest) { - _longest = sz; + if (sz > tmpLongest) { + tmpLongest = sz; } } } - shortest = _shortest; - longest = _longest; + this.shortest = tmpShortest; + this.longest = tmpLongest; } /** diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java index 70fb875a2..6121ea811 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java @@ -296,9 +296,10 @@ public class MethodUtilsTest { assertArrayEquals(a.getRight(), b.getRight()); } - static void verify(final ImmutablePair a, final Object _b) { - @SuppressWarnings("unchecked") final ImmutablePair b = (ImmutablePair) _b; - verify(a, b); + static void verify(final ImmutablePair a, final Object obj) { + @SuppressWarnings("unchecked") + final ImmutablePair pair = (ImmutablePair) obj; + verify(a, pair); } }