Skip to content

Commit 1703c21

Browse files
committed
Sort members
1 parent b8e98d1 commit 1703c21

10 files changed

Lines changed: 196 additions & 196 deletions

File tree

src/main/java/org/apache/commons/lang3/CachedRandomBits.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@
3737
*/
3838
final class CachedRandomBits {
3939

40-
private final Random random;
41-
42-
private final byte[] cache;
43-
44-
/**
45-
* Index of the next bit in the cache to be used.
46-
*
47-
* <ul>
48-
* <li>bitIndex=0 means the cache is fully random and none of the bits have been used yet.</li>
49-
* <li>bitIndex=1 means that only the LSB of cache[0] has been used and all other bits can be used.</li>
50-
* <li>bitIndex=8 means that only the 8 bits of cache[0] has been used.</li>
51-
* </ul>
52-
*/
53-
private int bitIndex;
54-
5540
/**
5641
* The maximum size of the cache.
5742
*
@@ -60,12 +45,27 @@ final class CachedRandomBits {
6045
* </p>
6146
*/
6247
private static final int MAX_CACHE_SIZE = Integer.MAX_VALUE >> 3;
48+
6349
/** Maximum number of bits that can be generated (size of an int) */
6450
private static final int MAX_BITS = 32;
51+
6552
/** Mask to extract the bit offset within a byte (0-7) */
6653
private static final int BIT_INDEX_MASK = 0x7;
54+
6755
/** Number of bits in a byte */
6856
private static final int BITS_PER_BYTE = 8;
57+
private final Random random;
58+
private final byte[] cache;
59+
/**
60+
* Index of the next bit in the cache to be used.
61+
*
62+
* <ul>
63+
* <li>bitIndex=0 means the cache is fully random and none of the bits have been used yet.</li>
64+
* <li>bitIndex=1 means that only the LSB of cache[0] has been used and all other bits can be used.</li>
65+
* <li>bitIndex=8 means that only the 8 bits of cache[0] has been used.</li>
66+
* </ul>
67+
*/
68+
private int bitIndex;
6969
/**
7070
* Creates a new instance.
7171
*

src/main/java/org/apache/commons/lang3/ClassUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
*/
5151
public class ClassUtils {
5252

53-
/**
54-
* The maximum number of array dimensions.
55-
*/
56-
private static final int MAX_DIMENSIONS = 255;
57-
5853
/**
5954
* Inclusivity literals for {@link #hierarchy(Class, Interfaces)}.
6055
*
@@ -69,6 +64,11 @@ public enum Interfaces {
6964
EXCLUDE
7065
}
7166

67+
/**
68+
* The maximum number of array dimensions.
69+
*/
70+
private static final int MAX_DIMENSIONS = 255;
71+
7272
private static final Comparator<Class<?>> COMPARATOR = (o1, o2) -> Objects.compare(getName(o1), getName(o2), String::compareTo);
7373

7474
/**

src/test/java/org/apache/commons/lang3/EnumUtilsTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
import org.junit.jupiter.api.Assertions;
3737
import org.junit.jupiter.api.Test;
3838

39+
enum Enum64 {
40+
A00, A01, A02, A03, A04, A05, A06, A07, A08, A09, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22,
41+
A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45,
42+
A46, A47, A48, A49, A50, A51, A52, A53, A54, A55, A56, A57, A58, A59, A60, A61, A62, A63
43+
}
44+
3945
/**
4046
*/
4147
class EnumUtilsTest extends AbstractLangTest {
@@ -601,12 +607,6 @@ void testProcessBitVectors_nullClass() {
601607

602608
}
603609

604-
enum Enum64 {
605-
A00, A01, A02, A03, A04, A05, A06, A07, A08, A09, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22,
606-
A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45,
607-
A46, A47, A48, A49, A50, A51, A52, A53, A54, A55, A56, A57, A58, A59, A60, A61, A62, A63
608-
}
609-
610610
enum Month {
611611
JAN(1), FEB(2), MAR(3), APR(4), MAY(5), JUN(6), JUL(7), AUG(8), SEP(9), OCT(10), NOV(11), DEC(12);
612612

src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ void testHomogeneity(final RandomStringUtils rsu) {
218218
assertTrue(chiSquare(expected, counts) < 23.025850929940457d, "test homogeneity -- will fail about 1 in 100,000 times");
219219
}
220220

221+
@ParameterizedTest
222+
@ValueSource(ints = {MAX_SAFE_COUNT, MAX_SAFE_COUNT + 1})
223+
@EnabledIfSystemProperty(named = "test.large.heap", matches = "true")
224+
void testHugeStrings(final int expectedLength) {
225+
final String hugeString = RandomStringUtils.random(expectedLength);
226+
assertEquals(expectedLength, hugeString.length(), "hugeString.length() == expectedLength");
227+
}
228+
221229
/**
222230
* Checks if the string got by {@link RandomStringUtils#random(int)} can be converted to UTF-8 and back without loss.
223231
*
@@ -807,12 +815,4 @@ void testRandomWithChars(final RandomStringUtils rsu) {
807815
assertNotEquals(r1, r3);
808816
assertNotEquals(r2, r3);
809817
}
810-
811-
@ParameterizedTest
812-
@ValueSource(ints = {MAX_SAFE_COUNT, MAX_SAFE_COUNT + 1})
813-
@EnabledIfSystemProperty(named = "test.large.heap", matches = "true")
814-
void testHugeStrings(final int expectedLength) {
815-
final String hugeString = RandomStringUtils.random(expectedLength);
816-
assertEquals(expectedLength, hugeString.length(), "hugeString.length() == expectedLength");
817-
}
818818
}

src/test/java/org/apache/commons/lang3/RegExUtilsTest.java

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,6 @@ void testRemoveAll() {
6767
assertEquals("", RegExUtils.removeAll((CharSequence) "<A>\nxy\n</A>", Pattern.compile("<A>.*</A>", Pattern.DOTALL)));
6868
}
6969

70-
@Test
71-
void testRemoveAllDeprecated() {
72-
assertNull(RegExUtils.removeAll(null, Pattern.compile("")));
73-
assertEquals("any", RegExUtils.removeAll("any", (Pattern) null));
74-
75-
assertEquals("any", RegExUtils.removeAll("any", Pattern.compile("")));
76-
assertEquals("", RegExUtils.removeAll("any", Pattern.compile(".*")));
77-
assertEquals("", RegExUtils.removeAll("any", Pattern.compile(".+")));
78-
assertEquals("", RegExUtils.removeAll("any", Pattern.compile(".?")));
79-
80-
assertEquals("A\nB", RegExUtils.removeAll("A<__>\n<__>B", Pattern.compile("<.*>")));
81-
assertEquals("AB", RegExUtils.removeAll("A<__>\n<__>B", Pattern.compile("(?s)<.*>")));
82-
assertEquals("ABC123", RegExUtils.removeAll("ABCabc123abc", Pattern.compile("[a-z]")));
83-
84-
assertEquals("AB", RegExUtils.removeAll("A<__>\n<__>B", Pattern.compile("<.*>", Pattern.DOTALL)));
85-
assertEquals("AB", RegExUtils.removeAll("A<__>\\n<__>B", Pattern.compile("<.*>")));
86-
assertEquals("", RegExUtils.removeAll("<A>x\\ny</A>", Pattern.compile("<A>.*</A>")));
87-
assertEquals("", RegExUtils.removeAll("<A>\nxy\n</A>", Pattern.compile("<A>.*</A>", Pattern.DOTALL)));
88-
}
89-
9070
@Test
9171
void testRemoveAll_StringString() {
9272
assertNull(RegExUtils.removeAll(null, ""));
@@ -107,6 +87,26 @@ void testRemoveAll_StringString() {
10787
"RegExUtils.removeAll expecting PatternSyntaxException");
10888
}
10989

90+
@Test
91+
void testRemoveAllDeprecated() {
92+
assertNull(RegExUtils.removeAll(null, Pattern.compile("")));
93+
assertEquals("any", RegExUtils.removeAll("any", (Pattern) null));
94+
95+
assertEquals("any", RegExUtils.removeAll("any", Pattern.compile("")));
96+
assertEquals("", RegExUtils.removeAll("any", Pattern.compile(".*")));
97+
assertEquals("", RegExUtils.removeAll("any", Pattern.compile(".+")));
98+
assertEquals("", RegExUtils.removeAll("any", Pattern.compile(".?")));
99+
100+
assertEquals("A\nB", RegExUtils.removeAll("A<__>\n<__>B", Pattern.compile("<.*>")));
101+
assertEquals("AB", RegExUtils.removeAll("A<__>\n<__>B", Pattern.compile("(?s)<.*>")));
102+
assertEquals("ABC123", RegExUtils.removeAll("ABCabc123abc", Pattern.compile("[a-z]")));
103+
104+
assertEquals("AB", RegExUtils.removeAll("A<__>\n<__>B", Pattern.compile("<.*>", Pattern.DOTALL)));
105+
assertEquals("AB", RegExUtils.removeAll("A<__>\\n<__>B", Pattern.compile("<.*>")));
106+
assertEquals("", RegExUtils.removeAll("<A>x\\ny</A>", Pattern.compile("<A>.*</A>")));
107+
assertEquals("", RegExUtils.removeAll("<A>\nxy\n</A>", Pattern.compile("<A>.*</A>", Pattern.DOTALL)));
108+
}
109+
110110
@Test
111111
void testRemoveFirst() {
112112
assertNull(RegExUtils.removeFirst((CharSequence) null, Pattern.compile("")));
@@ -123,22 +123,6 @@ void testRemoveFirst() {
123123
assertEquals("ABC123abc", RegExUtils.removeFirst((CharSequence) "ABCabc123abc", Pattern.compile("[a-z]+")));
124124
}
125125

126-
@Test
127-
void testRemoveFirstDeprecated() {
128-
assertNull(RegExUtils.removeFirst(null, Pattern.compile("")));
129-
assertEquals("any", RegExUtils.removeFirst("any", (Pattern) null));
130-
131-
assertEquals("any", RegExUtils.removeFirst("any", Pattern.compile("")));
132-
assertEquals("", RegExUtils.removeFirst("any", Pattern.compile(".*")));
133-
assertEquals("", RegExUtils.removeFirst("any", Pattern.compile(".+")));
134-
assertEquals("bc", RegExUtils.removeFirst("abc", Pattern.compile(".?")));
135-
136-
assertEquals("A\n<__>B", RegExUtils.removeFirst("A<__>\n<__>B", Pattern.compile("<.*>")));
137-
assertEquals("AB", RegExUtils.removeFirst("A<__>\n<__>B", Pattern.compile("(?s)<.*>")));
138-
assertEquals("ABCbc123", RegExUtils.removeFirst("ABCabc123", Pattern.compile("[a-z]")));
139-
assertEquals("ABC123abc", RegExUtils.removeFirst("ABCabc123abc", Pattern.compile("[a-z]+")));
140-
}
141-
142126
@Test
143127
void testRemoveFirst_StringString() {
144128
assertNull(RegExUtils.removeFirst(null, ""));
@@ -160,6 +144,22 @@ void testRemoveFirst_StringString() {
160144
"RegExUtils.removeFirst expecting PatternSyntaxException");
161145
}
162146

147+
@Test
148+
void testRemoveFirstDeprecated() {
149+
assertNull(RegExUtils.removeFirst(null, Pattern.compile("")));
150+
assertEquals("any", RegExUtils.removeFirst("any", (Pattern) null));
151+
152+
assertEquals("any", RegExUtils.removeFirst("any", Pattern.compile("")));
153+
assertEquals("", RegExUtils.removeFirst("any", Pattern.compile(".*")));
154+
assertEquals("", RegExUtils.removeFirst("any", Pattern.compile(".+")));
155+
assertEquals("bc", RegExUtils.removeFirst("abc", Pattern.compile(".?")));
156+
157+
assertEquals("A\n<__>B", RegExUtils.removeFirst("A<__>\n<__>B", Pattern.compile("<.*>")));
158+
assertEquals("AB", RegExUtils.removeFirst("A<__>\n<__>B", Pattern.compile("(?s)<.*>")));
159+
assertEquals("ABCbc123", RegExUtils.removeFirst("ABCabc123", Pattern.compile("[a-z]")));
160+
assertEquals("ABC123abc", RegExUtils.removeFirst("ABCabc123abc", Pattern.compile("[a-z]+")));
161+
}
162+
163163
@Test
164164
void testRemovePattern() {
165165
assertNull(RegExUtils.removePattern((CharSequence) null, ""));
@@ -219,31 +219,6 @@ void testReplaceAll() {
219219
assertEquals("Lorem_ipsum_dolor_sit", RegExUtils.replaceAll((CharSequence) "Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
220220
}
221221

222-
@Test
223-
void testReplaceAllDeprecated() {
224-
assertNull(RegExUtils.replaceAll(null, Pattern.compile(""), ""));
225-
226-
assertEquals("any", RegExUtils.replaceAll("any", (Pattern) null, ""));
227-
assertEquals("any", RegExUtils.replaceAll("any", Pattern.compile(""), null));
228-
229-
assertEquals("zzz", RegExUtils.replaceAll("", Pattern.compile(""), "zzz"));
230-
assertEquals("zzz", RegExUtils.replaceAll("", Pattern.compile(".*"), "zzz"));
231-
assertEquals("", RegExUtils.replaceAll("", Pattern.compile(".+"), "zzz"));
232-
assertEquals("ZZaZZbZZcZZ", RegExUtils.replaceAll("abc", Pattern.compile(""), "ZZ"));
233-
234-
assertEquals("z\nz", RegExUtils.replaceAll("<__>\n<__>", Pattern.compile("<.*>"), "z"));
235-
assertEquals("z", RegExUtils.replaceAll("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z"));
236-
237-
assertEquals("z", RegExUtils.replaceAll("<__>\n<__>", Pattern.compile("<.*>", Pattern.DOTALL), "z"));
238-
assertEquals("z", RegExUtils.replaceAll("<__>\\n<__>", Pattern.compile("<.*>"), "z"));
239-
assertEquals("X", RegExUtils.replaceAll("<A>\nxy\n</A>", Pattern.compile("<A>.*</A>", Pattern.DOTALL), "X"));
240-
241-
assertEquals("ABC___123", RegExUtils.replaceAll("ABCabc123", Pattern.compile("[a-z]"), "_"));
242-
assertEquals("ABC_123", RegExUtils.replaceAll("ABCabc123", Pattern.compile("[^A-Z0-9]+"), "_"));
243-
assertEquals("ABC123", RegExUtils.replaceAll("ABCabc123", Pattern.compile("[^A-Z0-9]+"), ""));
244-
assertEquals("Lorem_ipsum_dolor_sit", RegExUtils.replaceAll("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
245-
}
246-
247222
@Test
248223
void testReplaceAll_StringStringString() {
249224
assertNull(RegExUtils.replaceAll(null, "", ""));
@@ -270,6 +245,31 @@ void testReplaceAll_StringStringString() {
270245
"RegExUtils.replaceAll expecting PatternSyntaxException");
271246
}
272247

248+
@Test
249+
void testReplaceAllDeprecated() {
250+
assertNull(RegExUtils.replaceAll(null, Pattern.compile(""), ""));
251+
252+
assertEquals("any", RegExUtils.replaceAll("any", (Pattern) null, ""));
253+
assertEquals("any", RegExUtils.replaceAll("any", Pattern.compile(""), null));
254+
255+
assertEquals("zzz", RegExUtils.replaceAll("", Pattern.compile(""), "zzz"));
256+
assertEquals("zzz", RegExUtils.replaceAll("", Pattern.compile(".*"), "zzz"));
257+
assertEquals("", RegExUtils.replaceAll("", Pattern.compile(".+"), "zzz"));
258+
assertEquals("ZZaZZbZZcZZ", RegExUtils.replaceAll("abc", Pattern.compile(""), "ZZ"));
259+
260+
assertEquals("z\nz", RegExUtils.replaceAll("<__>\n<__>", Pattern.compile("<.*>"), "z"));
261+
assertEquals("z", RegExUtils.replaceAll("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z"));
262+
263+
assertEquals("z", RegExUtils.replaceAll("<__>\n<__>", Pattern.compile("<.*>", Pattern.DOTALL), "z"));
264+
assertEquals("z", RegExUtils.replaceAll("<__>\\n<__>", Pattern.compile("<.*>"), "z"));
265+
assertEquals("X", RegExUtils.replaceAll("<A>\nxy\n</A>", Pattern.compile("<A>.*</A>", Pattern.DOTALL), "X"));
266+
267+
assertEquals("ABC___123", RegExUtils.replaceAll("ABCabc123", Pattern.compile("[a-z]"), "_"));
268+
assertEquals("ABC_123", RegExUtils.replaceAll("ABCabc123", Pattern.compile("[^A-Z0-9]+"), "_"));
269+
assertEquals("ABC123", RegExUtils.replaceAll("ABCabc123", Pattern.compile("[^A-Z0-9]+"), ""));
270+
assertEquals("Lorem_ipsum_dolor_sit", RegExUtils.replaceAll("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
271+
}
272+
273273
@Test
274274
void testReplaceFirst() {
275275
assertNull(RegExUtils.replaceFirst((CharSequence) null, Pattern.compile(""), ""));
@@ -291,27 +291,6 @@ void testReplaceFirst() {
291291
assertEquals("Lorem_ipsum dolor sit", RegExUtils.replaceFirst((CharSequence) "Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
292292
}
293293

294-
@Test
295-
void testReplaceFirstDeprecated() {
296-
assertNull(RegExUtils.replaceFirst(null, Pattern.compile(""), ""));
297-
298-
assertEquals("any", RegExUtils.replaceFirst("any", (Pattern) null, ""));
299-
assertEquals("any", RegExUtils.replaceFirst("any", Pattern.compile(""), null));
300-
301-
assertEquals("zzz", RegExUtils.replaceFirst("", Pattern.compile(""), "zzz"));
302-
assertEquals("zzz", RegExUtils.replaceFirst("", Pattern.compile(".*"), "zzz"));
303-
assertEquals("", RegExUtils.replaceFirst("", Pattern.compile(".+"), "zzz"));
304-
assertEquals("ZZabc", RegExUtils.replaceFirst("abc", Pattern.compile(""), "ZZ"));
305-
306-
assertEquals("z\n<__>", RegExUtils.replaceFirst("<__>\n<__>", Pattern.compile("<.*>"), "z"));
307-
assertEquals("z", RegExUtils.replaceFirst("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z"));
308-
309-
assertEquals("ABC_bc123", RegExUtils.replaceFirst("ABCabc123", Pattern.compile("[a-z]"), "_"));
310-
assertEquals("ABC_123abc", RegExUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "_"));
311-
assertEquals("ABC123abc", RegExUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), ""));
312-
assertEquals("Lorem_ipsum dolor sit", RegExUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
313-
}
314-
315294
@Test
316295
void testReplaceFirst_StringStringString() {
317296
assertNull(RegExUtils.replaceFirst(null, "", ""));
@@ -339,6 +318,27 @@ void testReplaceFirst_StringStringString() {
339318
"RegExUtils.replaceFirst expecting PatternSyntaxException");
340319
}
341320

321+
@Test
322+
void testReplaceFirstDeprecated() {
323+
assertNull(RegExUtils.replaceFirst(null, Pattern.compile(""), ""));
324+
325+
assertEquals("any", RegExUtils.replaceFirst("any", (Pattern) null, ""));
326+
assertEquals("any", RegExUtils.replaceFirst("any", Pattern.compile(""), null));
327+
328+
assertEquals("zzz", RegExUtils.replaceFirst("", Pattern.compile(""), "zzz"));
329+
assertEquals("zzz", RegExUtils.replaceFirst("", Pattern.compile(".*"), "zzz"));
330+
assertEquals("", RegExUtils.replaceFirst("", Pattern.compile(".+"), "zzz"));
331+
assertEquals("ZZabc", RegExUtils.replaceFirst("abc", Pattern.compile(""), "ZZ"));
332+
333+
assertEquals("z\n<__>", RegExUtils.replaceFirst("<__>\n<__>", Pattern.compile("<.*>"), "z"));
334+
assertEquals("z", RegExUtils.replaceFirst("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z"));
335+
336+
assertEquals("ABC_bc123", RegExUtils.replaceFirst("ABCabc123", Pattern.compile("[a-z]"), "_"));
337+
assertEquals("ABC_123abc", RegExUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "_"));
338+
assertEquals("ABC123abc", RegExUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), ""));
339+
assertEquals("Lorem_ipsum dolor sit", RegExUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
340+
}
341+
342342
@Test
343343
void testReplacePattern() {
344344
assertNull(RegExUtils.replacePattern((CharSequence) null, "", ""));

0 commit comments

Comments
 (0)