Skip to content

Commit 5626d97

Browse files
committed
Handle null input explicitly in Lyndon factorization
1 parent b6df845 commit 5626d97

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/main/java/com/thealgorithms/strings/LyndonFactorization.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5-
import java.util.Objects;
65

76
/**
87
* Factorizes a string into its Lyndon words using Duval's algorithm.
@@ -25,10 +24,12 @@ private LyndonFactorization() {
2524
*
2625
* @param text input string to factorize
2726
* @return Lyndon factors in non-increasing lexicographic order
28-
* @throws NullPointerException if {@code text} is null
27+
* @throws IllegalArgumentException if {@code text} is null
2928
*/
3029
public static List<String> factorize(String text) {
31-
Objects.requireNonNull(text, "text must not be null");
30+
if (text == null) {
31+
throw new IllegalArgumentException("text must not be null");
32+
}
3233

3334
List<String> factors = new ArrayList<>();
3435
int n = text.length();

0 commit comments

Comments
 (0)