Skip to content

Commit 5a586d7

Browse files
committed
chore: Remove unused files and update project docs
1 parent c07d8ea commit 5a586d7

37 files changed

+266
-598
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
24-
replay_pid*
24+
replay_pid*

.idea/sonarlint/issuestore/1/0/1035b95fde851fd8381dabb4da89dd79908aed9b

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sonarlint/issuestore/5/8/5879b52636e240d2cfcbd5e54543d3959f957811

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sonarlint/issuestore/5/a/5a503c465e2e403dbd4c3fe2906c7cecc8e13602

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sonarlint/issuestore/d/c/dcba94fd99e9396082d1fedd3522764f78825365

Lines changed: 0 additions & 3 deletions
This file was deleted.

.idea/sonarlint/issuestore/f/9/f9465a1df802c670887a6edc9706fd150e19342b

Lines changed: 0 additions & 9 deletions
This file was deleted.

.idea/sonarlint/issuestore/index.pb

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sonarlint/securityhotspotstore/index.pb

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 58 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/io/github/multiform_validator/CnpjValidator.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
import java.util.Arrays;
44

55
public class CnpjValidator {
6+
// Prevent instantiation
67
private CnpjValidator() {
78
throw new IllegalStateException("Utility class");
89
}
910

11+
/**
12+
* Calculate the first verifier digit of a CNPJ
13+
*
14+
* @param cnpjBase an array of integers with the first 12 digits of a CNPJ
15+
* @return the first verifier digit
16+
*/
1017
private static int calculateFirstVerifier(int[] cnpjBase) {
1118
final int[] weight = {5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2};
1219
int sum = 0;
@@ -19,6 +26,13 @@ private static int calculateFirstVerifier(int[] cnpjBase) {
1926
return remainder < 2 ? 0 : 11 - remainder;
2027
}
2128

29+
/**
30+
* Calculate the second verifier digit of a CNPJ
31+
*
32+
* @param cnpjBase an array of integers with the first 12 digits of a CNPJ
33+
* @param firstVerifier the first verifier digit
34+
* @return the second verifier digit
35+
*/
2236
private static int calculateSecondVerifier(int[] cnpjBase, int firstVerifier) {
2337
final int[] weight = {6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2};
2438
int sum = 0;
@@ -33,9 +47,16 @@ private static int calculateSecondVerifier(int[] cnpjBase, int firstVerifier) {
3347
return remainder < 2 ? 0 : 11 - remainder;
3448
}
3549

50+
/**
51+
* Check if a CNPJ is valid
52+
*
53+
* @param cnpj the CNPJ to be validated
54+
* @return true if the CNPJ is valid, false otherwise
55+
* @throws NullPointerException if the CNPJ is null
56+
*/
3657
public static boolean cnpjIsValid(String cnpj) {
3758
if (cnpj == null) {
38-
throw new NullPointerException("CNPJ cannot be null or empty");
59+
throw new NullPointerException("CNPJ cannot be null");
3960
}
4061

4162
final String cnpjClean = cnpj.replaceAll("\\D", "");
@@ -67,4 +88,4 @@ public static boolean cnpjIsValid(String cnpj) {
6788

6889
return cnpjArray[12] == firstVerifier && cnpjArray[13] == secondVerifier;
6990
}
70-
}
91+
}

src/main/java/io/github/multiform_validator/CpfValidator.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44
import java.util.regex.Pattern;
55
import java.util.stream.IntStream;
66

7+
/**
8+
* The CpfValidator class provides a utility method to validate CPF (Cadastro de Pessoas Físicas) numbers.
9+
*/
710
public class CpfValidator {
11+
// Prevent instantiation
812
private CpfValidator() {
913
throw new IllegalStateException("Utility class");
1014
}
1115

16+
/**
17+
* Validates a CPF number.
18+
*
19+
* @param cpf the CPF number to validate
20+
* @return true if the CPF number is valid, false otherwise
21+
* @throws NullPointerException if the CPF number is null
22+
*/
1223
public static boolean cpfIsValid(String cpf) {
1324
if (cpf == null) {
14-
throw new NullPointerException("CPF cannot be null or empty");
25+
throw new NullPointerException("CPF cannot be null");
1526
}
1627

1728
final String cpfClean = cpf.replaceAll("\\D", "");
@@ -37,4 +48,4 @@ public static boolean cpfIsValid(String cpf) {
3748

3849
return cpfArray[9] == validator1 && cpfArray[10] == validator2;
3950
}
40-
}
51+
}

0 commit comments

Comments
 (0)