Skip to content

Commit 30e5768

Browse files
author
Gary Gregory
committed
Use final.
1 parent 4ddf436 commit 30e5768

18 files changed

Lines changed: 144 additions & 144 deletions

src/main/java/org/apache/commons/codec/binary/Base32.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ public boolean isInAlphabet(final byte octet) {
557557
*
558558
* @throws IllegalArgumentException if the bits being checked contain any non-zero value
559559
*/
560-
private void validateCharacter(int numBits, Context context) {
560+
private void validateCharacter(final int numBits, final Context context) {
561561
if ((context.lbitWorkArea & numBits) != 0) {
562562
throw new IllegalArgumentException(
563563
"Last encoded character (before the paddings if any) is a valid base 32 alphabet but not a possible value");

src/main/java/org/apache/commons/codec/binary/Base64.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ protected boolean isInAlphabet(final byte octet) {
793793
*
794794
* @throws IllegalArgumentException if the bits being checked contain any non-zero value
795795
*/
796-
private long validateCharacter(int numBitsToDrop, Context context) {
796+
private long validateCharacter(final int numBitsToDrop, final Context context) {
797797
if ((context.ibitWorkArea & numBitsToDrop) != 0) {
798798
throw new IllegalArgumentException(
799799
"Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value");

src/main/java/org/apache/commons/codec/digest/MurmurHash2.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ private MurmurHash2() {
4848
* @param seed initial seed value
4949
* @return 32 bit hash of the given array
5050
*/
51-
public static int hash32(final byte[] data, int length, int seed) {
51+
public static int hash32(final byte[] data, final int length, final int seed) {
5252
// 'm' and 'r' are mixing constants generated offline.
5353
// They're not really 'magic', they just happen to work well.
5454
final int m = 0x5bd1e995;
5555
final int r = 24;
5656

5757
// Initialize the hash to a random value
5858
int h = seed ^ length;
59-
int length4 = length / 4;
59+
final int length4 = length / 4;
6060

6161
for (int i = 0; i < length4; i++) {
6262
final int i4 = i * 4;
@@ -94,7 +94,7 @@ public static int hash32(final byte[] data, int length, int seed) {
9494
* @param length length of the array to hash
9595
* @return 32 bit hash of the given array
9696
*/
97-
public static int hash32(final byte[] data, int length) {
97+
public static int hash32(final byte[] data, final int length) {
9898
return hash32(data, length, 0x9747b28c);
9999
}
100100

@@ -117,7 +117,7 @@ public static int hash32(final String text) {
117117
* @param length length of the substring to hash
118118
* @return 32 bit hash of the given string
119119
*/
120-
public static int hash32(final String text, int from, int length) {
120+
public static int hash32(final String text, final int from, final int length) {
121121
return hash32(text.substring(from, from + length));
122122
}
123123

@@ -129,13 +129,13 @@ public static int hash32(final String text, int from, int length) {
129129
* @param seed initial seed value
130130
* @return 64 bit hash of the given array
131131
*/
132-
public static long hash64(final byte[] data, int length, int seed) {
132+
public static long hash64(final byte[] data, final int length, final int seed) {
133133
final long m = 0xc6a4a7935bd1e995L;
134134
final int r = 47;
135135

136136
long h = (seed & 0xffffffffl) ^ (length * m);
137137

138-
int length8 = length / 8;
138+
final int length8 = length / 8;
139139

140140
for (int i = 0; i < length8; i++) {
141141
final int i8 = i * 8;
@@ -184,7 +184,7 @@ public static long hash64(final byte[] data, int length, int seed) {
184184
* @param length length of the array to hash
185185
* @return 64 bit hash of the given string
186186
*/
187-
public static long hash64(final byte[] data, int length) {
187+
public static long hash64(final byte[] data, final int length) {
188188
return hash64(data, length, 0xe17a1465);
189189
}
190190

@@ -207,7 +207,7 @@ public static long hash64(final String text) {
207207
* @param length length of the substring to hash
208208
* @return 64 bit hash of the given array
209209
*/
210-
public static long hash64(final String text, int from, int length) {
210+
public static long hash64(final String text, final int from, final int length) {
211211
return hash64(text.substring(from, from + length));
212212
}
213213
}

src/main/java/org/apache/commons/codec/digest/MurmurHash3.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private MurmurHash3() {
8686
* @param l1 long to hash
8787
* @return 32 bit hash
8888
*/
89-
public static int hash32(long l0, long l1) {
89+
public static int hash32(final long l0, final long l1) {
9090
return hash32(l0, l1, DEFAULT_SEED);
9191
}
9292

@@ -96,7 +96,7 @@ public static int hash32(long l0, long l1) {
9696
* @param l0 long to hash
9797
* @return 32 bit hash
9898
*/
99-
public static int hash32(long l0) {
99+
public static int hash32(final long l0) {
100100
return hash32(l0, DEFAULT_SEED);
101101
}
102102

@@ -107,7 +107,7 @@ public static int hash32(long l0) {
107107
* @param seed initial seed value
108108
* @return 32 bit hash
109109
*/
110-
public static int hash32(long l0, int seed) {
110+
public static int hash32(final long l0, final int seed) {
111111
int hash = seed;
112112
final long r0 = Long.reverseBytes(l0);
113113

@@ -125,7 +125,7 @@ public static int hash32(long l0, int seed) {
125125
* @param seed initial seed value
126126
* @return 32 bit hash
127127
*/
128-
public static int hash32(long l0, long l1, int seed) {
128+
public static int hash32(final long l0, final long l1, final int seed) {
129129
int hash = seed;
130130
final long r0 = Long.reverseBytes(l0);
131131
final long r1 = Long.reverseBytes(l1);
@@ -144,7 +144,7 @@ public static int hash32(long l0, long l1, int seed) {
144144
* @param data - input byte array
145145
* @return 32 bit hash
146146
*/
147-
public static int hash32(byte[] data) {
147+
public static int hash32(final byte[] data) {
148148
return hash32(data, 0, data.length, DEFAULT_SEED);
149149
}
150150

@@ -154,8 +154,8 @@ public static int hash32(byte[] data) {
154154
* @param data - input string
155155
* @return 32 bit hash
156156
*/
157-
public static int hash32(String data) {
158-
byte[] origin = data.getBytes();
157+
public static int hash32(final String data) {
158+
final byte[] origin = data.getBytes();
159159
return hash32(origin, 0, origin.length, DEFAULT_SEED);
160160
}
161161

@@ -166,7 +166,7 @@ public static int hash32(String data) {
166166
* @param length - length of array
167167
* @return 32 bit hash
168168
*/
169-
public static int hash32(byte[] data, int length) {
169+
public static int hash32(final byte[] data, final int length) {
170170
return hash32(data, length, DEFAULT_SEED);
171171
}
172172

@@ -178,7 +178,7 @@ public static int hash32(byte[] data, int length) {
178178
* @param seed - seed. (default 0)
179179
* @return 32 bit hash
180180
*/
181-
public static int hash32(byte[] data, int length, int seed) {
181+
public static int hash32(final byte[] data, final int length, final int seed) {
182182
return hash32(data, 0, length, seed);
183183
}
184184

@@ -191,21 +191,21 @@ public static int hash32(byte[] data, int length, int seed) {
191191
* @param seed - seed. (default 0)
192192
* @return 32 bit hash
193193
*/
194-
public static int hash32(byte[] data, int offset, int length, int seed) {
194+
public static int hash32(final byte[] data, final int offset, final int length, final int seed) {
195195
int hash = seed;
196196
final int nblocks = length >> 2;
197197

198198
// body
199199
for (int i = 0; i < nblocks; i++) {
200-
int i_4 = i << 2;
201-
int k = (data[offset + i_4] & 0xff) | ((data[offset + i_4 + 1] & 0xff) << 8)
200+
final int i_4 = i << 2;
201+
final int k = (data[offset + i_4] & 0xff) | ((data[offset + i_4 + 1] & 0xff) << 8)
202202
| ((data[offset + i_4 + 2] & 0xff) << 16) | ((data[offset + i_4 + 3] & 0xff) << 24);
203203

204204
hash = mix32(k, hash);
205205
}
206206

207207
// tail
208-
int idx = nblocks << 2;
208+
final int idx = nblocks << 2;
209209
int k1 = 0;
210210
switch (length - idx) {
211211
case 3:
@@ -232,7 +232,7 @@ public static int hash32(byte[] data, int offset, int length, int seed) {
232232
* @param data - input byte array
233233
* @return 64 bit hash
234234
*/
235-
public static long hash64(byte[] data) {
235+
public static long hash64(final byte[] data) {
236236
return hash64(data, 0, data.length, DEFAULT_SEED);
237237
}
238238

@@ -243,10 +243,10 @@ public static long hash64(byte[] data) {
243243
* @param data - input long
244244
* @return 64 bit hash
245245
*/
246-
public static long hash64(long data) {
246+
public static long hash64(final long data) {
247247
long hash = DEFAULT_SEED;
248248
long k = Long.reverseBytes(data);
249-
int length = LONG_BYTES;
249+
final int length = LONG_BYTES;
250250
// mix functions
251251
k *= C1;
252252
k = Long.rotateLeft(k, R1);
@@ -266,9 +266,9 @@ public static long hash64(long data) {
266266
* @param data - input int
267267
* @return 64 bit hash
268268
*/
269-
public static long hash64(int data) {
269+
public static long hash64(final int data) {
270270
long k1 = Integer.reverseBytes(data) & (-1L >>> 32);
271-
int length = INTEGER_BYTES;
271+
final int length = INTEGER_BYTES;
272272
long hash = DEFAULT_SEED;
273273
k1 *= C1;
274274
k1 = Long.rotateLeft(k1, R1);
@@ -287,7 +287,7 @@ public static long hash64(int data) {
287287
* @param data - input short
288288
* @return 64 bit hash
289289
*/
290-
public static long hash64(short data) {
290+
public static long hash64(final short data) {
291291
long hash = DEFAULT_SEED;
292292
long k1 = 0;
293293
k1 ^= ((long) data & 0xff) << 8;
@@ -312,7 +312,7 @@ public static long hash64(short data) {
312312
* @param length - length of array
313313
* @return 64 bit hash
314314
*/
315-
public static long hash64(byte[] data, int offset, int length) {
315+
public static long hash64(final byte[] data, final int offset, final int length) {
316316
return hash64(data, offset, length, DEFAULT_SEED);
317317
}
318318

@@ -325,7 +325,7 @@ public static long hash64(byte[] data, int offset, int length) {
325325
* @param seed - seed. (default 0)
326326
* @return 64 bit hash
327327
*/
328-
public static long hash64(byte[] data, int offset, int length, int seed) {
328+
public static long hash64(final byte[] data, final int offset, final int length, final int seed) {
329329
long hash = seed;
330330
final int nblocks = length >> 3;
331331

@@ -347,7 +347,7 @@ public static long hash64(byte[] data, int offset, int length, int seed) {
347347

348348
// tail
349349
long k1 = 0;
350-
int tailStart = nblocks << 3;
350+
final int tailStart = nblocks << 3;
351351
switch (length - tailStart) {
352352
case 7:
353353
k1 ^= ((long) data[offset + tailStart + 6] & 0xff) << 48;
@@ -382,7 +382,7 @@ public static long hash64(byte[] data, int offset, int length, int seed) {
382382
* @param data - input byte array
383383
* @return - 128 bit hash (2 longs)
384384
*/
385-
public static long[] hash128(byte[] data) {
385+
public static long[] hash128(final byte[] data) {
386386
return hash128(data, 0, data.length, DEFAULT_SEED);
387387
}
388388

@@ -392,8 +392,8 @@ public static long[] hash128(byte[] data) {
392392
* @param data - input String
393393
* @return - 128 bit hash (2 longs)
394394
*/
395-
public static long[] hash128(String data) {
396-
byte[] origin = data.getBytes();
395+
public static long[] hash128(final String data) {
396+
final byte[] origin = data.getBytes();
397397
return hash128(origin, 0, origin.length, DEFAULT_SEED);
398398
}
399399

@@ -406,7 +406,7 @@ public static long[] hash128(String data) {
406406
* @param seed - seed. (default is 0)
407407
* @return - 128 bit hash (2 longs)
408408
*/
409-
public static long[] hash128(byte[] data, int offset, int length, int seed) {
409+
public static long[] hash128(final byte[] data, final int offset, final int length, final int seed) {
410410
long h1 = seed;
411411
long h2 = seed;
412412
final int nblocks = length >> 4;
@@ -446,7 +446,7 @@ public static long[] hash128(byte[] data, int offset, int length, int seed) {
446446
// tail
447447
long k1 = 0;
448448
long k2 = 0;
449-
int tailStart = nblocks << 4;
449+
final int tailStart = nblocks << 4;
450450
switch (length - tailStart) {
451451
case 15:
452452
k2 ^= (long) (data[offset + tailStart + 14] & 0xff) << 48;
@@ -513,7 +513,7 @@ private static int mix32(int k, int hash) {
513513
return Integer.rotateLeft(hash, R2_32) * M_32 + N_32;
514514
}
515515

516-
private static int fmix32(int length, int hash) {
516+
private static int fmix32(final int length, int hash) {
517517
hash ^= length;
518518
hash ^= (hash >>> 16);
519519
hash *= 0x85ebca6b;
@@ -539,12 +539,12 @@ public static class IncrementalHash32 {
539539
int totalLen;
540540
int hash;
541541

542-
public final void start(int hash) {
542+
public final void start(final int hash) {
543543
tailLen = totalLen = 0;
544544
this.hash = hash;
545545
}
546546

547-
public final void add(byte[] data, int offset, int length) {
547+
public final void add(final byte[] data, int offset, final int length) {
548548
if (length == 0) {
549549
return;
550550
}
@@ -578,12 +578,12 @@ public final void add(byte[] data, int offset, int length) {
578578
hash ^= k;
579579
hash = Integer.rotateLeft(hash, R2_32) * M_32 + N_32;
580580
}
581-
int length2 = length - offset2;
581+
final int length2 = length - offset2;
582582
offset += offset2;
583583
final int nblocks = length2 >> 2;
584584

585585
for (int i = 0; i < nblocks; i++) {
586-
int i_4 = (i << 2) + offset;
586+
final int i_4 = (i << 2) + offset;
587587
int k = orBytes(data[i_4], data[i_4 + 1], data[i_4 + 2], data[i_4 + 3]);
588588

589589
// mix functions
@@ -594,7 +594,7 @@ public final void add(byte[] data, int offset, int length) {
594594
hash = Integer.rotateLeft(hash, R2_32) * M_32 + N_32;
595595
}
596596

597-
int consumed = (nblocks << 2);
597+
final int consumed = (nblocks << 2);
598598
tailLen = length2 - consumed;
599599
if (consumed == length2) {
600600
return;
@@ -630,7 +630,7 @@ public final int end() {
630630
}
631631
}
632632

633-
private static int orBytes(byte b1, byte b2, byte b3, byte b4) {
633+
private static int orBytes(final byte b1, final byte b2, final byte b3, final byte b4) {
634634
return (b1 & 0xff) | ((b2 & 0xff) << 8) | ((b3 & 0xff) << 16) | ((b4 & 0xff) << 24);
635635
}
636636
}

src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static String sha256Crypt(final byte[] keyBytes, String salt) {
133133
* when a {@link java.security.NoSuchAlgorithmException} is caught.
134134
* @since 1.12
135135
*/
136-
public static String sha256Crypt(final byte[] keyBytes, String salt, Random random) {
136+
public static String sha256Crypt(final byte[] keyBytes, String salt, final Random random) {
137137
if (salt == null) {
138138
salt = SHA256_PREFIX + B64.getRandomSalt(8, random);
139139
}

src/main/java/org/apache/commons/codec/language/ColognePhonetic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ private static boolean arrayContains(final char[] arr, final char key) {
309309
* @param text The source text to encode
310310
* @return the corresponding encoding according to the <i>K&ouml;lner Phonetik</i> algorithm
311311
*/
312-
public String colognePhonetic(String text) {
312+
public String colognePhonetic(final String text) {
313313
if (text == null) {
314314
return null;
315315
}
@@ -414,7 +414,7 @@ public boolean isEncodeEqual(final String text1, final String text2) {
414414
* <li>small sharp s, German</li>
415415
* </ul>
416416
*/
417-
private char[] preprocess(String text) {
417+
private char[] preprocess(final String text) {
418418
// This converts German small sharp s (Eszett) to SS
419419
final char[] chrs = text.toUpperCase(Locale.GERMAN).toCharArray();
420420

0 commit comments

Comments
 (0)